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

Function jsonpReq

lib/test/angular/1.7.0/angular.js:13038–13073  ·  view source on GitHub ↗
(url, callbackPath, done)

Source from the content-addressed store, hash-verified

13036 };
13037
13038 function jsonpReq(url, callbackPath, done) {
13039 url = url.replace('JSON_CALLBACK', callbackPath);
13040 // we can't use jQuery/jqLite here because jQuery does crazy stuff with script elements, e.g.:
13041 // - fetches local scripts via XHR and evals them
13042 // - adds and immediately removes script elements from the document
13043 var script = rawDocument.createElement('script'), callback = null;
13044 script.type = 'text/javascript';
13045 script.src = url;
13046 script.async = true;
13047
13048 callback = function(event) {
13049 script.removeEventListener('load', callback);
13050 script.removeEventListener('error', callback);
13051 rawDocument.body.removeChild(script);
13052 script = null;
13053 var status = -1;
13054 var text = 'unknown';
13055
13056 if (event) {
13057 if (event.type === 'load' && !callbacks.wasCalled(callbackPath)) {
13058 event = { type: 'error' };
13059 }
13060 text = event.type;
13061 status = event.type === 'error' ? 404 : 200;
13062 }
13063
13064 if (done) {
13065 done(status, text);
13066 }
13067 };
13068
13069 script.addEventListener('load', callback);
13070 script.addEventListener('error', callback);
13071 rawDocument.body.appendChild(script);
13072 return callback;
13073 }
13074}
13075
13076var $interpolateMinErr = angular.$interpolateMinErr = minErr('$interpolate');

Callers 1

createHttpBackendFunction · 0.70

Calls 1

doneFunction · 0.70

Tested by

no test coverage detected