Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

PHP and jQuery...

Posted on 2013-01-25
5
Medium Priority
?
268 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 84

Accepted Solution

by:
Dave Baldwin earned 700 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 600 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 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 700 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

610 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