5

此问题已在 PlayStation 3、4、Xbox360、Xbox One 上重现。所有版本的 AjaxPro 都存在此问题。

当发出 Ajax 请求(使用 AjaxPro)时,服务器会返回正确的内容。但是,回调函数中返回的对象是

{
   "error": 
    {
     "Message":"","Type":"ConnectFailure","Status":200},"value":null,
     "request":
     {
       "method":"MethodName",
       "args":
       {
          "Argument1":"1111","Argument2":"2222"
       }
     },
    "context":null,"duration":18
   }
}
4

3 回答 3

10

就我而言,在将 AjaxPro 与 https、TLS 1.2、ECDHE_RSA 与 P-256 密钥交换和 AES_256_GCM 密码(IE11+、Chrome51+、Firefox49+)一起使用时,我遇到了同样的错误。请在此处查看)。它可以使用带有 HMAC-SHA1 密码的过时 AES_256_CBC 运行。

问题是服务器响应后XMLHttpRequest.statusText属性为空(我真的不知道为什么)并且AjaxPro.Request.prototype.doStateChange方法(ajaxpro/core.ashx 文件)期望“OK”将响应视为有效:

var res = this.getEmptyRes();
if(this.xmlHttp.status == 200 && this.xmlHttp.statusText == "OK") {
    res = this.createResponse(res);
} else {
    res = this.createResponse(res, true);
    res.error = {Message:this.xmlHttp.statusText,Type:"ConnectFailure",Status:this.xmlHttp.status};
}

我最终决定重写AjaxPro.Request.prototype.doStateChange方法并在this.xmlHttp.statusText中允许一个空值。

我将此脚本添加到受影响的页面中:

$(function() {
    if (typeof AjaxPro != 'undefined' && AjaxPro && AjaxPro.Request && AjaxPro.Request.prototype) {
        AjaxPro.Request.prototype.doStateChange = function () {
            this.onStateChanged(this.xmlHttp.readyState, this);
            if (this.xmlHttp.readyState != 4 || !this.isRunning) {
                return;
            }
            this.duration = new Date().getTime() - this.__start;
            if (this.timeoutTimer != null) {
                clearTimeout(this.timeoutTimer);
            }
            var res = this.getEmptyRes();
            if (this.xmlHttp.status == 200 && (this.xmlHttp.statusText == "OK" || !this.xmlHttp.statusText)) {
                res = this.createResponse(res);
            } else {
                res = this.createResponse(res, true);
                res.error = { Message: this.xmlHttp.statusText, Type: "ConnectFailure", Status: this.xmlHttp.status };
            }
            this.endRequest(res);
        };
    }
});
于 2017-01-25T15:06:24.863 回答
4

建立在此之前的所有答案的基础上,并供其他寻找此问题的人参考 - 在我们的情况下,我们将其追踪到 HTTP2 协议(注意 - 我们正在通过 HTTPS 进行测试;我不确定 HTTP 是否存在问题...)。
- 当我们在浏览器(或服务器上的 IIS)中禁用 HTTP2 时,AjaxPro 调用正常工作。
- 但是,当使用 HTTP2 时,响应是简单的“200”而不是“200 OK”,AjaxPro 将其解释为失败

于 2018-09-22T22:27:13.583 回答
2

这个问题的提示在

"Message":""

AjaxPro 的 core.ashx 文件是使用 core.js 生成的

在 core.js 中,以下代码负责在收到服务器的响应时生成响应对象。

   if (this.xmlHttp.status == 200 && this.xmlHttp.statusText == "OK") {
        res = this.createResponse(res);
    } else {
        res = this.createResponse(res, true);
        res.error = { Message: this.xmlHttp.statusText, Type: "ConnectFailure", Status: this.xmlHttp.status };
    }

由于某种原因,已识别平台上的浏览器不会将 xmlHttp.statusText 返回为“OK”。相反,它是空的。这会导致 AjaxPro 陷入“ConnectionFailure”子句。

于 2014-09-22T19:31:02.577 回答