Geschrieben
von Duc Ngo Viet
am Montag, 16 April 2012.
Veröffentlicht in Webdesign
Hello to all friends of webdesign out there! We're currently working on a project which is about getting Data from another server and therefore I'm going to show you how to get started with JSONP, why you maybe should use it and what you can do with it.
For those of you who haven't heard of JSON before have a look here. The P at JSONP stands for JSON with Padding and is a cross-domain method to get a JSON Object from another server. This usually won't work with JSON because of the Same Origin Policy. To overcome this JSONP comes in action.
In my little example we'll use the getJSON() method from jQuery and Apples Search API to load an image and display it.
After understanding the core concept of getting data from another server with JSONP and any JSONP supported API you'll be able to create your own apps like maybe a dynamic fotogallery with the Flickr API, an own Facebook app with the Facebook API or an own map with Google Map API.
At the end of this tutorial I'll also show you some alternatives to get the JSONP with jQuery functions $.get() and $.ajax(), so keep on reading ;).
CHECK OUT THE DEMO DOWNLOAD EXAMPLE FILES
Demo: type in a name of a software and click on the search button.