javascript - why can't I see the script tag injected by jquery in jsonp request? -
i familiar jsonp , how works, i'm noticing confusing.
when using jquery's $.ajax method datatype of "jsonp" every account have read suggests jquery inject script tag dom issue request.
my code works (on bare bones test page), when inspect chrome dev tools i'm not seeing injected script tag. gives?
$.ajax({ url: "https://status.github.com/api/status.json", datatype: "jsonp", type: "get", success: function( response ) { console.log( response ); // logs data github } });
when looking @ network tab, url jquery requests:
also, jquery put function?
function jquery2130779439534759149_1434721871588(){ // success callback presume }
this read on web (and noted down ref) while ago. jquery adds script tag dom until callback (success function) done executing. tag added header. adds function window object called on return.
jquery2130779439534759149_1434721871588
object living on window object , dynamically added function. when function done executing, remove window object.
the callback related function (from minified jquery source) looks following.
function(q){n=q;b();d();z[i]=v;try{delete z[i]}catch(p){}a&&a.removechild(b)}
hope helps.
Comments
Post a Comment