Skip to Content
JavaScript & jQuery: The Missing Manual, 2nd Edition
book

JavaScript & jQuery: The Missing Manual, 2nd Edition

by David Sawyer McFarland
October 2011
Intermediate to advanced
535 pages
18h 20m
English
O'Reilly Media, Inc.
Content preview from JavaScript & jQuery: The Missing Manual, 2nd Edition

Chapter 12. Flickr and Google Maps

In the previous chapter, you learned the basics of Ajax: what it is, how it works, and how jQuery can simplify the process of Ajax programming. Since Ajax is all about the two-way communication between web browser and web server, understanding server-side programming is necessary if you really want to harness Ajax’s power. However, you don’t need to be a server-side programming guru to use Ajax successfully. In fact, you can take advantage of the services offered by popular websites like Flickr, Twitter, and Google Maps to retrieve photos, tweets, and maps, and place them directly inside your web pages.

Introducing JSONP

In the last chapter you learned that, for security reasons, Ajax requests are limited to the same domain. That is, the page making an Ajax request must be on the same server as the page responding to the request. This is a policy enforced by the web browser to keep one site from maliciously attempting to contact another site (like your bank). There’s one way around that however. While a web browser can’t send an XMLHTTP request to a different website, it can download resources from other sites, including pictures, style sheets, and external JavaScript files.

JSONP (which stands for JSON with padding) provides one way to retrieve information from another site. Basically, instead of making an Ajax request of the foreign site, you load a script that contains the JSON code in it. In other words, it’s like linking to an external JavaScript ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

JavaScript & jQuery: The Missing Manual, 3rd Edition

JavaScript & jQuery: The Missing Manual, 3rd Edition

David Sawyer McFarland
JavaScript: Best Practice

JavaScript: Best Practice

James Kolce, Moritz Kroger, Ivan Curic, Samier Saeed, Jeff Mott, M. David Green, Craig Buckler

Publisher Resources

ISBN: 9781449317812Errata Page