Engaged employer
Write your own script that does a JSONP request, without using jQuery. Should work with multiple calls to the function and support async.
Anonymous
function jsonpCaller(URL, callback) { var returnScript, fName; // Need a random name to avoid collisions: fName = (new Date()).getTime() + '_' + Math.floor(Math.random()*1001); returnScript = document.createElement('script'); returnScript.src = URL + (URL.indexOf("?") > -1 ? "&" : "?") + 'callback=' + fName; returnScript.async = true; window[fName] = function(data) { callback(data); window[fName] = null; // Clean up a bit } // How to handle errors? use a setTimeOut to delay and then window[fName] = null; // ...or (don't think this works in IE tho): returnScript.onerror = function() { window[fName] = null; // plus whatever add. error handling you want } }
Check out your Company Bowl for anonymous work chats.