Skip to content

Instantly share code, notes, and snippets.

@gaishimo
Created July 22, 2013 08:11
Show Gist options
  • Save gaishimo/6052141 to your computer and use it in GitHub Desktop.
Save gaishimo/6052141 to your computer and use it in GitHub Desktop.
jsonpのサンプル (クライアント側)
var JSONP_API = {};
function loadJS(src){
var script = document.createElement('script');
script.src = src;
var body = document.body;
body.appendChild(script);
}
JSONP_API.callback1 = function(data){
console.log("callback1", data);
};
loadJS('http://127.0.0.1:3000/api?callback=JSONP_API.callback1' );
JSONP_API.callback2 = function(data){
console.log("callback2", data);
};
loadJS('http://127.0.0.1:3000/api?callback=JSONP_API.callback2' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment