MCPcopy Create free account
hub / github.com/EricSimons/ionic-course / jsonpReq

Function jsonpReq

code/songhop/www/lib/angular/angular.js:9809–9843  ·  view source on GitHub ↗
(url, callbackId, done)

Source from the content-addressed store, hash-verified

9807 };
9808
9809 function jsonpReq(url, callbackId, done) {
9810 // we can't use jQuery/jqLite here because jQuery does crazy shit with script elements, e.g.:
9811 // - fetches local scripts via XHR and evals them
9812 // - adds and immediately removes script elements from the document
9813 var script = rawDocument.createElement('script'), callback = null;
9814 script.type = "text/javascript";
9815 script.src = url;
9816 script.async = true;
9817
9818 callback = function(event) {
9819 removeEventListenerFn(script, "load", callback);
9820 removeEventListenerFn(script, "error", callback);
9821 rawDocument.body.removeChild(script);
9822 script = null;
9823 var status = -1;
9824 var text = "unknown";
9825
9826 if (event) {
9827 if (event.type === "load" && !callbacks[callbackId].called) {
9828 event = { type: "error" };
9829 }
9830 text = event.type;
9831 status = event.type === "error" ? 404 : 200;
9832 }
9833
9834 if (done) {
9835 done(status, text);
9836 }
9837 };
9838
9839 addEventListenerFn(script, "load", callback);
9840 addEventListenerFn(script, "error", callback);
9841 rawDocument.body.appendChild(script);
9842 return callback;
9843 }
9844}
9845
9846var $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