Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 6cd328f

Browse files
author
Ricardo Bin
committed
.defaults.useXDomain to works with and
1 parent ca99791 commit 6cd328f

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

src/ng/http.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ function $HttpProvider() {
698698
// if we won't have the response in cache, send the request to the backend
699699
if (!cachedResp) {
700700
$httpBackend(config.method, url, reqData, done, reqHeaders, config.timeout,
701-
config.withCredentials, config.useXDomain);
701+
config.withCredentials, config.useXDomain || $http.defaults.useXDomain);
702702
}
703703

704704
return promise;

src/ng/httpBackend.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var XHR = window.XMLHttpRequest || function() {
33
try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); } catch (e2) {}
44
try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e3) {}
55
throw new Error("This browser does not support XMLHttpRequest.");
6-
}, XDR = window.XDomainRequest || null;
6+
}, XDR = !window.msPerformance && window.XDomainRequest || null;
77

88

99
/**
@@ -44,13 +44,13 @@ function createHttpBackend($browser, XHR, XDR, $browserDefer, callbacks, rawDocu
4444

4545
jsonpReq(url.replace('JSON_CALLBACK', 'angular.callbacks.' + callbackId),
4646
function() {
47-
if (callbacks[callbackId].data) {
48-
completeRequest(callback, 200, callbacks[callbackId].data);
49-
} else {
50-
completeRequest(callback, -2);
51-
}
52-
delete callbacks[callbackId];
53-
});
47+
if (callbacks[callbackId].data) {
48+
completeRequest(callback, 200, callbacks[callbackId].data);
49+
} else {
50+
completeRequest(callback, -2);
51+
}
52+
delete callbacks[callbackId];
53+
});
5454
} else {
5555
var status;
5656
if (useXDomain && XDR) {
@@ -60,6 +60,7 @@ function createHttpBackend($browser, XHR, XDR, $browserDefer, callbacks, rawDocu
6060
// Required to XDomainRequest works
6161
xdr.timeout = timeout;
6262
xdr.onprogress = function() {};
63+
6364
xdr.ontimeout = function() {
6465
completeRequest(callback, 408, 'Timeout', 'Content-Type: text/plain');
6566
xdr.abort();
@@ -75,7 +76,9 @@ function createHttpBackend($browser, XHR, XDR, $browserDefer, callbacks, rawDocu
7576
};
7677

7778

78-
setTimeout(xdr.send, 0); //fix IE bug that raises '$apply already in progress' on cached requests
79+
$browserDefer(function () {
80+
xdr.send();
81+
}, 0); //fix IE bug that raises '$apply already in progress' on cached requests
7982

8083
if (timeout > 0) {
8184
$browserDefer(function() {

src/ngResource/resource.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,8 @@ angular.module('ngResource', ['ng']).
362362
$http({
363363
method: action.method,
364364
url: route.url(extend({}, extractParams(data), action.params || {}, params)),
365-
data: data
365+
data: data,
366+
useXDomain: $http.defaults.useXDomain || false
366367
}).then(function(response) {
367368
var data = response.data;
368369

0 commit comments

Comments
 (0)