MCPcopy Index your code
hub / github.com/angular-ui/ui-router / jsonpReq

Function jsonpReq

test/angular/1.5/angular.js:12296–12331  ·  view source on GitHub ↗
(url, callbackPath, done)

Source from the content-addressed store, hash-verified

12294 };
12295
12296 function jsonpReq(url, callbackPath, done) {
12297 url = url.replace('JSON_CALLBACK', callbackPath);
12298 // we can't use jQuery/jqLite here because jQuery does crazy stuff with script elements, e.g.:
12299 // - fetches local scripts via XHR and evals them
12300 // - adds and immediately removes script elements from the document
12301 var script = rawDocument.createElement('script'), callback = null;
12302 script.type = 'text/javascript';
12303 script.src = url;
12304 script.async = true;
12305
12306 callback = function(event) {
12307 removeEventListenerFn(script, 'load', callback);
12308 removeEventListenerFn(script, 'error', callback);
12309 rawDocument.body.removeChild(script);
12310 script = null;
12311 var status = -1;
12312 var text = 'unknown';
12313
12314 if (event) {
12315 if (event.type === 'load' && !callbacks.wasCalled(callbackPath)) {
12316 event = { type: 'error' };
12317 }
12318 text = event.type;
12319 status = event.type === 'error' ? 404 : 200;
12320 }
12321
12322 if (done) {
12323 done(status, text);
12324 }
12325 };
12326
12327 addEventListenerFn(script, 'load', callback);
12328 addEventListenerFn(script, 'error', callback);
12329 rawDocument.body.appendChild(script);
12330 return callback;
12331 }
12332}
12333
12334var $interpolateMinErr = angular.$interpolateMinErr = minErr('$interpolate');

Callers 1

createHttpBackendFunction · 0.70

Calls 3

removeEventListenerFnFunction · 0.70
doneFunction · 0.70
addEventListenerFnFunction · 0.70

Tested by

no test coverage detected