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 ...

Get JavaScript and JSON Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.