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

Function jsonpReq

test/angular/1.4/angular.js:11075–11109  ·  view source on GitHub ↗
(url, callbackId, done)

Source from the content-addressed store, hash-verified

11073 };
11074
11075 function jsonpReq(url, callbackId, done) {
11076 // we can't use jQuery/jqLite here because jQuery does crazy stuff with script elements, e.g.:
11077 // - fetches local scripts via XHR and evals them
11078 // - adds and immediately removes script elements from the document
11079 var script = rawDocument.createElement('script'), callback = null;
11080 script.type = "text/javascript";
11081 script.src = url;
11082 script.async = true;
11083
11084 callback = function(event) {
11085 removeEventListenerFn(script, "load", callback);
11086 removeEventListenerFn(script, "error", callback);
11087 rawDocument.body.removeChild(script);
11088 script = null;
11089 var status = -1;
11090 var text = "unknown";
11091
11092 if (event) {
11093 if (event.type === "load" && !callbacks[callbackId].called) {
11094 event = { type: "error" };
11095 }
11096 text = event.type;
11097 status = event.type === "error" ? 404 : 200;
11098 }
11099
11100 if (done) {
11101 done(status, text);
11102 }
11103 };
11104
11105 addEventListenerFn(script, "load", callback);
11106 addEventListenerFn(script, "error", callback);
11107 rawDocument.body.appendChild(script);
11108 return callback;
11109 }
11110}
11111
11112var $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