Building a jQuery AJAX method

In this section, we will learn to develop a jQuery AJAX method in order to make server calls. The following figure shows the block diagram of a typical communication between a client and a server done through a sequence of requests and responses, where each request is triggered by an AJAX call:

Building a jQuery AJAX method

jQuery provides an AJAX method $.ajax() to call the remote data. For our application, we will call our servlet ProductServlet to download the product list in the JSON format. The AJAX method makes an XMLHttpRequest request to the servlet to get the data.

The syntax for the AJAX method is shown as follows:

$.ajax(<url>,{configuration ...

Get Developing Responsive Web Applications with AJAX and jQuery now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.