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:

https://status.github.com/api/status.json?callback=jquery2130779439534759149_1434721871588&_=1434721871589

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

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -

jdbc - Not able to establish database connection in eclipse -