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

Function jsonpReq

lib/test/angular/1.6.7/angular.js:12867–12902  ·  view source on GitHub ↗
(url, callbackPath, done)

Source from the content-addressed store, hash-verified

12865 };
12866
12867 function jsonpReq(url, callbackPath, done) {
12868 url = url.replace('JSON_CALLBACK', callbackPath);
12869 // we can't use jQuery/jqLite here because jQuery does crazy stuff with script elements, e.g.:
12870 // - fetches local scripts via XHR and evals them
12871 // - adds and immediately removes script elements from the document
12872 var script = rawDocument.createElement('script'), callback = null;
12873 script.type = 'text/javascript';
12874 script.src = url;
12875 script.async = true;
12876
12877 callback = function(event) {
12878 script.removeEventListener('load', callback);
12879 script.removeEventListener('error', callback);
12880 rawDocument.body.removeChild(script);
12881 script = null;
12882 var status = -1;
12883 var text = 'unknown';
12884
12885 if (event) {
12886 if (event.type === 'load' && !callbacks.wasCalled(callbackPath)) {
12887 event = { type: 'error' };
12888 }
12889 text = event.type;
12890 status = event.type === 'error' ? 404 : 200;
12891 }
12892
12893 if (done) {
12894 done(status, text);
12895 }
12896 };
12897
12898 script.addEventListener('load', callback);
12899 script.addEventListener('error', callback);
12900 rawDocument.body.appendChild(script);
12901 return callback;
12902 }
12903}
12904
12905var $interpolateMinErr = angular.$interpolateMinErr = minErr('$interpolate');

Callers 1

createHttpBackendFunction · 0.70

Calls 1

doneFunction · 0.70

Tested by

no test coverage detected