Solved

PHP and jQuery...

Posted on 2013-01-25
5
241 Views
Last Modified: 2013-02-09
Please comment on the following statements and questions (please don't use yes/no as answer if you can explain it a bit):

A- jQuery makes it easy the use  and replaces javascript manipulation of DOM.
B- Is there some areas jQuery cannot do what javascript does?
C- Can jQuery be utilized in server-side php files? If so, please give an example.

Thank you.
0
Comment
Question by:Mike Eghtebas
5 Comments
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 175 total points
ID: 38820683
jQuery is a javascript library.  It does not 'replace' javascript, it is javascript.  jQuery and javascript run in the browser, PHP runs on the server.  jQuery will not run on the server in PHP.  PHP can deliver it to the browser in the HTML output where it can be used.
0
 
LVL 16

Assisted Solution

by:kiranvj
kiranvj earned 150 total points
ID: 38821610
A- jQuery makes it easy the use  and replaces javascript manipulation of DOM.

Partially correct. jQuery makes it easy but does not replaces any core JavaScript functions. jQuery is build on top of existing JavaScript functions. jQuery has lot of functions to make DOM manipulations easy. We can do the DOM manipulation with plain JavaScript, in that case we need to write more lines of code and the code has to be compatible with different browser versions. If we are using jQuery, it does all this extra effort and provide us a function, we just need to call this function with correct parameters. In effect jQuery does all the low level programming effort and browser compactability issues, we only need to focus on our application logic.


B- Is there some areas jQuery cannot do what javascript does?

Lots of, thats why jQuery is providing the option to extend it. We can write our on plugins in Javascript or with available jQuery functions on top of jQuery core library.

C- Can jQuery be utilized in server-side php files? If so, please give an example.

Yes and No.

We can write jQuery in PHP files but it will be executed only in client browser environment.

For eg:

something like

<?php
if( $domId == "textbox-my-id") // this is PHP
{
?>
<script>
var getElement = $("#<?php  echo($domId=); ?>"); // This is JS, but will executed only in browser

</script>
<?php
}
?>

Open in new window



hope this helps,
kiranvj
0
 
LVL 109

Assisted Solution

by:Ray Paseur
Ray Paseur earned 175 total points
ID: 38822325
A- jQuery makes it easy the use and replaces javascript manipulation of DOM.

jQuery implements the "good parts" of JavaScript in a language framework.  It does not replace any part of JavaScript - it just makes it easier to use.

B- Is there some areas jQuery cannot do what javascript does?

jQuery is a framework that implements JavaScript.  JavaScript can be thought of as a low-level language.  It will have more functionality and will be more customisable than jQuery, but only at a low level.  Both can exists side-by-side in client-side applications.

C- Can jQuery be utilized in server-side php files? If so, please give an example.

No.  It runs on the client, not the server.  But more to the point, jQuery can facilitate communication between the client and the server.  This article shows the "hello world" exercise with a handshake between jQuery on the client and PHP on the server.
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Jquery/A_10712-The-Hello-World-Exercise-with-jQuery-and-PHP.html
0
 
LVL 34

Author Closing Comment

by:Mike Eghtebas
ID: 38871928
Thank you
0
 
LVL 16

Expert Comment

by:kiranvj
ID: 38872368
Thx for the points and grade. Good to know it helped.
0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question