I am trying to execute a cross-domain query with an XMLHttpRequest object because with $.ajaxit it does not work in IE, only in Chrome, Firefox and Safari. Below is a sample code
$("#btn").click(function () {
CallWithXhr();
});
function CallWithXhr() {
var xhr = new XMLHttpRequest();
xhr.open("POST", "https://www.sandbox.paypal.com/cgi-bin/webscr", true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader("Access-Control-Allow-Origin", "*");
xhr.send();
xhr.onload = function () {
var responseText = xhr.responseText;
console.log(responseText);
};
xhr.onerror = function () {
console.log('There was an error!');
};
}
I need this call because I want to add the item to my Paypal shopping cart without being redirected to the Paypal shopping cart. I did this with $.ajax, but it did not work in Internet Explorer 10 and 11.
The errors I get in IE are as follows:
SEC7126: Redirects are not allowed for CORS preflight requests.
SCRIPT7002: XMLHttpRequest: Network Error 0x80070005, Access is denied.
In Chrome, I have only one error for this script:
XMLHttpRequest https://www.sandbox.paypal.com/cgi-bin/webscr. 'https://www.sandbox.paypal.com/home', , .
?
!