MCPcopy Create free account
hub / github.com/cafebazaar/blacksmith / jsonpReq

Function jsonpReq

web/static/bower_components/angular/angular.js:10749–10783  ·  view source on GitHub ↗
(url, callbackId, done)

Source from the content-addressed store, hash-verified

10747 };
10748
10749 function jsonpReq(url, callbackId, done) {
10750 // we can't use jQuery/jqLite here because jQuery does crazy stuff with script elements, e.g.:
10751 // - fetches local scripts via XHR and evals them
10752 // - adds and immediately removes script elements from the document
10753 var script = rawDocument.createElement('script'), callback = null;
10754 script.type = "text/javascript";
10755 script.src = url;
10756 script.async = true;
10757
10758 callback = function(event) {
10759 removeEventListenerFn(script, "load", callback);
10760 removeEventListenerFn(script, "error", callback);
10761 rawDocument.body.removeChild(script);
10762 script = null;
10763 var status = -1;
10764 var text = "unknown";
10765
10766 if (event) {
10767 if (event.type === "load" && !callbacks[callbackId].called) {
10768 event = { type: "error" };
10769 }
10770 text = event.type;
10771 status = event.type === "error" ? 404 : 200;
10772 }
10773
10774 if (done) {
10775 done(status, text);
10776 }
10777 };
10778
10779 addEventListenerFn(script, "load", callback);
10780 addEventListenerFn(script, "error", callback);
10781 rawDocument.body.appendChild(script);
10782 return callback;
10783 }
10784}
10785
10786var $interpolateMinErr = angular.$interpolateMinErr = minErr('$interpolate');

Callers 1

createHttpBackendFunction · 0.85

Calls 3

removeEventListenerFnFunction · 0.85
addEventListenerFnFunction · 0.85
doneFunction · 0.70

Tested by

no test coverage detected