Created
June 28, 2013 08:43
-
-
Save adrianvlupu/5883374 to your computer and use it in GitHub Desktop.
JSONP js wrapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var JSONP = { | |
_jsonpcallbacks: {}, | |
request: function (url, data, callback) { | |
var callbackName = Math.random(); | |
Ripple._jsonpcallbacks[callbackName] = callback; | |
var script = document.createElement('script'); | |
script.src = url + '?callback=' + callbackName + '&data=' + encodeURIComponent(JSON.stringify(data)); | |
script.type = 'text/javascript'; | |
document.getElementsByTagName('head')[0].appendChild(script); | |
} | |
} | |
JSONP.request('http://localhost:51097/channel.ashx', {name:'adi'}, function(d){ | |
console.log(d); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment