Solved

PHP and jQuery...

Posted on 2013-01-25
5
232 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 82

Accepted Solution

by:
Dave Baldwin earned 175 total points
Comment Utility
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
Comment Utility
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 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 175 total points
Comment Utility
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
Comment Utility
Thank you
0
 
LVL 16

Expert Comment

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

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now