Book Image

PHP Ajax Cookbook

Book Image

PHP Ajax Cookbook

Overview of this book

Table of Contents (16 chapters)
PHP Ajax Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Using Flickr API with Ajax


In this section, we will look at using Flickr API to retrieve images from Flickr.com with the specified search tag that is input from the textbox. In this section, we will see how to use the JSONP web services provided by Flickr using jQuery to get the response directly in JavaScript itself and parse it and display it. We're not using PHP in this example.

Getting ready

JSONP , JSON with padding, is an enhanced format of JSON data in which JSON data is wrapped inside function calls, which allows a page to access the data from a different domain. JSONP allows us cross-domain communication with the help of the <script> element. The XMLHttpRequest object of JavaScript, which is widely used in Ajax applications, is not capable of cross-domain communication due to restrictions of modern browsers. JSONP comes in handy to overcome such situations.

Now, let's try to understand how JSONP works. JSONP is nothing more than arbitrary JavaScript code that is executed as a...