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

Function jsonpReq

lib/test/angular/1.4.3/angular.js:10541–10575  ·  view source on GitHub ↗
(url, callbackId, done)

Source from the content-addressed store, hash-verified

10539 };
10540
10541 function jsonpReq(url, callbackId, done) {
10542 // we can't use jQuery/jqLite here because jQuery does crazy stuff with script elements, e.g.:
10543 // - fetches local scripts via XHR and evals them
10544 // - adds and immediately removes script elements from the document
10545 var script = rawDocument.createElement('script'), callback = null;
10546 script.type = "text/javascript";
10547 script.src = url;
10548 script.async = true;
10549
10550 callback = function(event) {
10551 removeEventListenerFn(script, "load", callback);
10552 removeEventListenerFn(script, "error", callback);
10553 rawDocument.body.removeChild(script);
10554 script = null;
10555 var status = -1;
10556 var text = "unknown";
10557
10558 if (event) {
10559 if (event.type === "load" && !callbacks[callbackId].called) {
10560 event = { type: "error" };
10561 }
10562 text = event.type;
10563 status = event.type === "error" ? 404 : 200;
10564 }
10565
10566 if (done) {
10567 done(status, text);
10568 }
10569 };
10570
10571 addEventListenerFn(script, "load", callback);
10572 addEventListenerFn(script, "error", callback);
10573 rawDocument.body.appendChild(script);
10574 return callback;
10575 }
10576}
10577
10578var $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