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

Function jsonpReq

lib/test/angular/1.8.0/angular.js:13672–13707  ·  view source on GitHub ↗
(url, callbackPath, done)

Source from the content-addressed store, hash-verified

13670 };
13671
13672 function jsonpReq(url, callbackPath, done) {
13673 url = url.replace('JSON_CALLBACK', callbackPath);
13674 // we can't use jQuery/jqLite here because jQuery does crazy stuff with script elements, e.g.:
13675 // - fetches local scripts via XHR and evals them
13676 // - adds and immediately removes script elements from the document
13677 var script = rawDocument.createElement('script'), callback = null;
13678 script.type = 'text/javascript';
13679 script.src = url;
13680 script.async = true;
13681
13682 callback = function(event) {
13683 script.removeEventListener('load', callback);
13684 script.removeEventListener('error', callback);
13685 rawDocument.body.removeChild(script);
13686 script = null;
13687 var status = -1;
13688 var text = 'unknown';
13689
13690 if (event) {
13691 if (event.type === 'load' && !callbacks.wasCalled(callbackPath)) {
13692 event = { type: 'error' };
13693 }
13694 text = event.type;
13695 status = event.type === 'error' ? 404 : 200;
13696 }
13697
13698 if (done) {
13699 done(status, text);
13700 }
13701 };
13702
13703 script.addEventListener('load', callback);
13704 script.addEventListener('error', callback);
13705 rawDocument.body.appendChild(script);
13706 return callback;
13707 }
13708}
13709
13710var $interpolateMinErr = angular.$interpolateMinErr = minErr('$interpolate');

Callers 1

createHttpBackendFunction · 0.70

Calls 1

doneFunction · 0.70

Tested by

no test coverage detected