我有一个使用XMLHttpRequest对象的Javascript函数,但是我一直返回的状态是0。我已经做了很多搜索,而我所想的只是0是一个不确定的错误,可能是由无数的原因引起的。原因。因此,我希望你们能在我的代码中发现错误。

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");
    }


提前致谢。

编辑:我在代码中添加了一个withCredentials行,但这似乎没有什么不同。
    var parameters =“ SessionId =” + ID +“&SST =” +令牌;
            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(参数)
            window.open(“ IPPPage.html”);

最佳答案

要与https://demo.ippayments.com.au/access/index.aspx的IPPayments页正确集成,您需要使用直接过帐方法。代替使用XMLHttpRequest对象,而使用HTML表单提交ID和令牌。例如 -

<form action="https://demo.ippayments.com.au/access/index.aspx" method="post">
    <input type="hidden" name="SST" value="1243123123123123123"/>
    <input type="hidden" name="SessionID" value="53535434535345"/>
    <input type="submit" value="submit" />
</form>

08-24 21:38