Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
JavaScript and JSON Essentials

You're reading from   JavaScript and JSON Essentials If you fancy a less verbose data format than CSV or XML, then JSON could be for you. This tutorial will teach you about using JSON with JavaScript for effective local storage or Internet transfers.

Arrow left icon
Product type Paperback
Published in Oct 2013
Publisher Packt
ISBN-13 9781783286034
Length 120 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Sai S Sriparasa Sai S Sriparasa
Author Profile Icon Sai S Sriparasa
Sai S Sriparasa
Arrow right icon
View More author details
Toc

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

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at R$50/month. Cancel anytime