tags:

views:

179

answers:

7

I heard that AJAX use xml concept. But I had some doubt that whether the following code is JQUERY or AJAX. Find it for me. Give me differences between Jquery and AJAX

$(".changepass").click(function() {
   $(".loading").show();
   $(".block1").load("views/changepass.template.php", function(){ $(".loading").hide(); });
   return false;
 }
+11  A: 

jQuery is a JavaScript library. AJAX, which means Asynchronous JavaScript and XML is a technique.

AJAX is...

used on the client-side to create interactive web applications or rich Internet applications. With Ajax, web applications can retrieve data from the server asynchronously in the background without interfering with the display and behavior of the existing page.

The $(<selector>) notation you are using is using the jQuery library. You can learn more about jQuery by visiting the site.

The .load() method in your code uses AJAX to asynchronously load whatever is being return by that PHP function to the $(<selector>).

Source (added from voyager's comment): Jquery Ajax

Randell
voyager
For clarity, I would probably say $(<selector>)
Marc
Right!
Randell
A: 

jQuery is a Javascript library. AJAX is a combination of XML, Javascript and the HTTP request.

The code you're showing here is obviously jQuery, and thus, Javascript. Certainly no AJAX, as it is not a language.

JorenB
Ajax does not have to use xml.
MrHus
True, but it's what the name stands for. It actually isn't even necessarily Javascript, not even necessarily asynchronous ;-) So, for the sake of simplicity, I put it this way. Sharp, though, so +1!
JorenB
There is AJAX in his code becuase he's using the .load() command which uses the XMLHTTPRequest object
Russ Cam
A: 

Your code is jQuery.

Read about jQuery here: link text

ilivewithian
+1  A: 

jQuery is a javascript library. It's especially useful because it uses CSS3 selectors (the query part) to find elements on the page, and so is quite powerful with minimal syntax.

AJAX stands for Asynchronous Javascript and Xml. Originally AJAX implementations used the XmlHttp ActiveX components Microsoft provided for web based Outlook access. Later browsers (FX, IE6 and above, everything else) included it as a built in component.

However XmlHttp methods that AJAX uses can fit above any HTTP call, and so many calls use JSON or HTML instead. So ajax now means any asynchronous javascript method that calls the server.

jQuery includes an Ajax library, as do most Javascript frameworks.

Keith
A: 

AJAX is a collection of technologies that enable richer user experience to the web application users by providing ways to send request to the web server "in the background" (asynchronous - A part of ajax) and update part of a page instead of refreshing the whole page. JQUERY is just a framework that helps you implement AJAX features in your web application.

Senad Uka
+1  A: 

The code is in jQuery and is used to load HTML from a remote file and inject it into the DOM. In this case you are injecting the HTML to an element with class 'block1'.

$(".changepass").click

attaches a clink event to element with class 'changepass'

See click

$(".loading").show();

show an element with class 'loading'

See show

$(".block1").load

loads an HTML to element with class 'block1' using AJAX.

See load

rahul
A: 

Neither of them.

because code and development technique are uncomparable
because your code does not look like this

For more info check other answers. Should be enough. :)

Arnis L.