MCPcopy
hub / github.com/angular-ui/ui-router / jsonpReq

Function jsonpReq

test/angular/1.3/angular.js:9920–9954  ·  view source on GitHub ↗
(url, callbackId, done)

Source from the content-addressed store, hash-verified

9918 };
9919
9920 function jsonpReq(url, callbackId, done) {
9921 // we can't use jQuery/jqLite here because jQuery does crazy stuff with script elements, e.g.:
9922 // - fetches local scripts via XHR and evals them
9923 // - adds and immediately removes script elements from the document
9924 var script = rawDocument.createElement('script'), callback = null;
9925 script.type = "text/javascript";
9926 script.src = url;
9927 script.async = true;
9928
9929 callback = function(event) {
9930 removeEventListenerFn(script, "load", callback);
9931 removeEventListenerFn(script, "error", callback);
9932 rawDocument.body.removeChild(script);
9933 script = null;
9934 var status = -1;
9935 var text = "unknown";
9936
9937 if (event) {
9938 if (event.type === "load" && !callbacks[callbackId].called) {
9939 event = { type: "error" };
9940 }
9941 text = event.type;
9942 status = event.type === "error" ? 404 : 200;
9943 }
9944
9945 if (done) {
9946 done(status, text);
9947 }
9948 };
9949
9950 addEventListenerFn(script, "load", callback);
9951 addEventListenerFn(script, "error", callback);
9952 rawDocument.body.appendChild(script);
9953 return callback;
9954 }
9955}
9956
9957var $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