MCPcopy Create free account
hub / github.com/angular-ui/ui-grid / jsonpReq

Function jsonpReq

lib/test/angular/1.5.0/angular.js:11469–11503  ·  view source on GitHub ↗
(url, callbackId, done)

Source from the content-addressed store, hash-verified

11467 };
11468
11469 function jsonpReq(url, callbackId, done) {
11470 // we can't use jQuery/jqLite here because jQuery does crazy stuff with script elements, e.g.:
11471 // - fetches local scripts via XHR and evals them
11472 // - adds and immediately removes script elements from the document
11473 var script = rawDocument.createElement('script'), callback = null;
11474 script.type = "text/javascript";
11475 script.src = url;
11476 script.async = true;
11477
11478 callback = function(event) {
11479 removeEventListenerFn(script, "load", callback);
11480 removeEventListenerFn(script, "error", callback);
11481 rawDocument.body.removeChild(script);
11482 script = null;
11483 var status = -1;
11484 var text = "unknown";
11485
11486 if (event) {
11487 if (event.type === "load" && !callbacks[callbackId].called) {
11488 event = { type: "error" };
11489 }
11490 text = event.type;
11491 status = event.type === "error" ? 404 : 200;
11492 }
11493
11494 if (done) {
11495 done(status, text);
11496 }
11497 };
11498
11499 addEventListenerFn(script, "load", callback);
11500 addEventListenerFn(script, "error", callback);
11501 rawDocument.body.appendChild(script);
11502 return callback;
11503 }
11504}
11505
11506var $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