I have a Javascript function using an XMLHttpRequest object, but the status I keep getting returned is 0. I've done lots of searching, and all I've come up with is that 0 is an undefined error and can be caused by a myriad of reasons. As such, I'm hoping you guys can spot the error in my code.
function initiateIPP(ID, Token)
{
var POSTRequest = new XMLHttpRequest();
POSTRequest.onreadystatechange = function ()
{
if (POSTRequest.readyState == 4)
{
if (POSTRequest.status == 200)
{
}
else
{
alert("An error has occured, response code = " + POSTRequest.status);
}
}
}
var parameters = "SessionId=" + ID + "&SST=" + Token;
POSTRequest.open("POST", "https://demo.ippayments.com.au/access/index.aspx", true)
POSTRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
POSTRequest.send(parameters)
window.open("IPPPage.html");
}
Thanks in advance.
EDIT: I added a withCredentials line to my code but that doesn't seem to have made a difference. var parameters = "SessionId=" + ID + "&SST=" + Token; POSTRequest.withCredentials = true; POSTRequest.open("POST", "https://demo.ippayments.com.au/access/index.aspx", true) POSTRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded") POSTRequest.send(parameters) window.open("IPPPage.html");
--disable-web-securityflag to your chrome browser...--disable-web-securitywill only solve the issue for him.