Solved

PHP and jQuery...

Posted on 2013-01-25
5
237 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 33

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP installation issues 11 59
javascript comparing two dates 3 18
JqueryUI sortable append variable to post 1 35
Mouse event to control image and transparency. 4 16
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
The viewer will learn how to dynamically set the form action using jQuery.
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.

785 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