Solved

PHP and jQuery...

Posted on 2013-01-25
5
254 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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:Kiran Paul VJ
Kiran Paul VJ 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 110

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:Kiran Paul VJ
ID: 38872368
Thx for the points and grade. Good to know it helped.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

691 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