Testing Ajax Calls

Learn about the basic structure of Ajax calls and how to write tests for Ajax calls.

Now that we have the internal logic of the task list working let’s focus on how to get data into and out of this code. The previous version of the code read the tasks essentially from the DOM, but in this case, we’ll make a separate Ajax call to get that information from the server. Let’s talk about strategies to test Ajax calls.

Ajax requests structure

Here’s the basic structure of an Ajax call. This one uses jQuery, but the basic idea holds no matter how the call gets made:

Get hands-on with 1400+ tech skills courses.