// function to make cross domain call
// adding the script tag to the head
var head = document.getElementsByTagName(‘head’);
var script = document.createElement(‘script’);
script.src = url;
// fire the loading
//handle the json
<button id=”load” onclick=’loadScript(“url&callback=callbackfn”)’>Deals</button>
The following link is an app that is used to get deals around you using jsonp to make the call to an external API.
Jquery’s .ajax() method can be used to make cross domain requests but the app would be much lighter if we use JSONP since we dont have to include the jquery library.
JSONP is only useful if we have to make GET request to the external domain. We can’t use POST as a request method