jQuery Ajax

What is Ajax

Ajax stands for Asynchronous JavaScript And XML. Ajax is a method used to fetch data from a server to a web browser without reloading the entire page.

Essentially, Ajax leverages the XMLHttpRequest object in JavaScript to send and receive data to and from a web server asynchronously, in the background, without disrupting the user's interaction.

Ajax has become widely adopted, with many applications incorporating it in some capacity. Examples of prominent Ajax-driven online services include Gmail, Google Maps, Google Docs, YouTube, Facebook, Flickr, among others.

Note: Ajax is not a new technology, in fact, Ajax is not even really a technology at all. Ajax is just a term to describe the process of exchanging data from a web server asynchronously through JavaScript, without a page refresh.


Ajax with jQuery

Various browsers handle Ajax implementations differently, requiring different code for each browser when using traditional JavaScript methods.

However, jQuery simplifies Ajax implementation by managing these browser discrepancies. It provides straightforward methods like load(), $.get(), $.post(), etc., ensuring consistent functionality across all browsers.

In the upcoming sections, you'll learn how to retrieve data from a server and how to send and receive data using HTTP GET and POST methods with jQuery Ajax.

Tip: Ajax requests are initiated by JavaScript code. Your code sends a request to a URL, and upon completion of the request, a callback function can be triggered to process the response. Importantly, because the request is asynchronous, the remainder of your code continues to execute while the request is being handled.