The AJAX call is a way of calling server-side script from the client side in an efficient way. It is possible to simply use GlideRecord on the client side, but this is not considered best practice. It is worth remembering that every time we call the server from the client side, we have to make a round-trip from the client to the server and back again. This takes time and shows as a delay in front of the user. Therefore, we want to reduce the amount of server calls we make, and ensure that any we do are as efficient as possible.
An AJAX call can perform multiple GlideRecord queries on the server, which saves us having to perform multiple calls to the server. For the AJAX call to work, we need to have some client-side script and some server-side script. This is most commonly a client script and a script include; we'll look at script includes further in a later chapter...