The problem with cross-domain AJAX calls
All the asynchronous calls that we have made until now have been on the same server. There are situations where we would want to load data from a different domain, such as fetching data from other APIs. Server-side programs are designed to handle these kinds of calls; we can use cURL to make HTTP calls to different domains to fetch such data. This increases our dependency on server-side programs as we would have to make a call to our server, which would in turn make a call to another domain to fetch the data, which would be returned to a client-side program. It might come across as being a trivial issue, but we are adding an extra layer to our web architecture. To avoid making a server-side call, let us try and see if we can make an asynchronous call to a different domain. For this example, let us use Reddit's JSON API to fetch the data.

This is similar to the asynchronous calls that we have made earlier to retrieve data from our students
API. It is...