jQuery和Ajax

I'm very new to ajax and jquery. i'm trying to understand below examples.

http://www.w3schools.com/ajax/tryit.asp?filename=tryajax_first

http://www.codeproject.com/Articles/17203/Using-jQuery-for-AJAX-in-ASP-NET

first examples does not use jquery and it uses XMLHttpRequest for sending and receiving data asynchronously but in the second example it uses jquery and i need to know why the XMLHttpRequest object is not in use?

jquery is a javascript library. the jquery $.ajax() method uses the XMLHttpRequest from javascript behind the scences.

XMLHttpRequest in the raw browser object that jQuery wraps into a more usable and simplified form and cross browser consistent functionality.

jQuery.ajax is a general Ajax requester in jQuery that can do any type and content requests.

jQuery.get and jQuery.post on the other hand can only issue GET and POST requests. If you don't know what these are, you should check HTTP protocol and learn a little. Internally these two functions use jQuery.ajax but they use particular settings that you don't have to set yourself thus simplifying GET or POST request compared to using jQuery.ajax. GET and POST being the most used HTTP methods anyway (compared to DELETE, PUT, HEAD or even other seldom used exotics).

All jQuery functions use XMLHttpRequest object in the background, but provide additional functionality that you don't have to do yourself.

Difference Between jQuery and AJAX

There are multiple of languages that can be used in making a web page nowadays, some are even not even unique but just a derivative of another language. jQuery is one of these derivatives. It is a lightweight library of JavasScript that focuses more on interactions with HTML elements. AJAX, on the other hand, is not a specific technology but a combination of varying technologies to provide a new functionality. Whenever you request a new set of data from web site, it clears the whole page and loads the new one. AJAX is used to circumvent this behavior and allow new data to be retrieved without modifying the whole page.

Summary:

  1. JQuery is a lightweight client side scripting library while AJAX is a combination of technologies used to provide asynchronous data transfer
  2. jQuery and AJAX are often used in conjunction with each other
  3. jQuery is primarily used to modify data on the screen dynamically and it uses AJAX to retrieve data that it needs without changing the current state of the displayed page
  4. Heavy usage of AJAX functions often cause server overload due to the greater number of connections made

Read more: Difference Between jQuery and AJAX | Difference Between | jQuery vs AJAX http://www.differencebetween.net/technology/difference-between-jquery-and-ajax/#ixzz2EWrAP000