Quick Introduction to jQuery AJAX

Asynchronous JavaScript And XML (AJAX) makes it possible to load data in the background and display it without refreshing the page. AJAX helps you develop more interactive web applications.

AJAX uses an object of XMLHttpRequest for the communication between the application and the server.

Here is the work flow of AJAX:

  • Javascript call goes to XMLHttpRequest object upon user action (Button press, Mouse over etc)
  • XMLHttpRequest object sends HTTP Request to the server.
  • Server received data and interacts with the database if needed.
  • Server processes the data and sends the result back to the XMLHttpRequest callback function.
  • Output(HTML, CSS) is displayed on the webpage.

jQuery and AJAX:

Different browsers have different syntax for AJAX. This makes it hard for the developers to write AJAX code that supports all the browsers. This issue has been solved by the jQuery since it takes care of the browser compatibility.

jQuery Methods:

The load() method loads data from the server and shows the result in the selected element.

The get() and post() methods are used to request data from the server.

jQuery uses the dollar sign ($) as a shortcut or alias for jQuery. It can cause conflict, if you have another Javascript library along with jQuery that also uses $ sign as shortcut. jQuery has a special method to deal this situation. This method is called noConflict() Method. Using noConflict(), you can set alias for the jQuery shortcut.

.entry-meta
#post-

Leave a Reply