转载自 https://my.oschina.net/shuaihong/blog/1542554
= myJsonp function (URL, Data, the callback) { var fnName = 'myJsonp_' + Math.random () toString () Replace.. (, '' '.' ); // define a global callback window [fnName] = the callback; // initialization sequence parameter var QueryString = '' ; for ( var attr in Data) { QueryString + + attr = '=' + Data [attr] + '&' ; } // dynamically created script tag var script = document.createElement ( 'Script' ); // backstage to accept the callback, and call '?' script.src = url + + querystring + 'callback ='+ fnName; //When processing is complete, remove the script tag, repeated requests otherwise, there will be a plurality of page script tag script.onload = function () { document.body.removeChild (script); } document.body.appendChild (script); }