YUI asyncRequest:缺少 POST 参数

发布于 2025-01-04 20:29:58 字数 1883 浏览 4 评论 0原文

我正在使用 YUI 2.6 和 Struts 1.2 java Web 应用程序。

我在 POST asyncRequest 方面遇到间歇性问题。服务器收到的某些请求没有任何参数。

大多数时候它工作得很好。重现非常困难,并且仅在我们的客户机器上发生。我们无法在我们的环境中繁殖。我花了很长时间才找到根本原因。

Web 浏览器是 IE 7、8 或 9。如果有任何帮助,我将不胜感激。

我查看了 此博客 但没有帮助,因为我正在记录请求和参数的某些部分,其中内容类型标头正确到达服务器。

代码:

new AjaxWrapper().asyncRequest( "<%=request.getContextPath()%>" + "/ajax/setValues.do",
{
    numberCheck: numberCheck,
    documentId: docBean.documentId,
    values: JSON.stringify( valueMap ),
    applyToF: applyToFCheckbox.checked,
    codeExternalF: (applyToFCheckbox.checked && codeExternalF.checked),
    applyToN: applyToNCheckbox.checked,
    codeExternalN: (applyToNCheckbox.checked && codeExternalN.checked)
},
{
    success: function( messageBeanJsonList, response, argument ) {
        // some code here
    },
    failure: function( messages ) {
        // some code here
    },
    after: function( messageBeanJsonList, response, argument ) {
        // some code here
    }, 
    argument: { codingPanel: mainCodingPanel, changedValues: changedValues }
},
AjaxWrapper.Methods.Post
);

对参数进行编码的方法:

_encodeParameters: function(parameters) {       
    var params = new Array();

    if (parameters) {
        for(var name in parameters) {
            if (YAHOO.lang.isArray(parameters[name])) {
                for(var i=0; i<parameters[name].length; i++) {
                    params.push(encodeURIComponent(name) + "=" + encodeURIComponent(parameters[name][i]));
                }
            }
            else {
                params.push(encodeURIComponent(name) + "=" + encodeURIComponent(parameters[name]));
            }
        }
    }

    return params.join("&");
}

I am using YUI 2.6 with Struts 1.2 java web application.

I am getting an intermittent issue with POST asyncRequest. Some of the requests that the server receives do not have any parameters.

Most of the the times it works fine. It is very difficult to reproduce and it happens only with our customer machines. We have not been able to reproduce at our environment. I have spent quite some time to find the root cause.

Web browsers are IE 7, 8 or 9. I would appreciate any help.

I looked at this blog but did not help because I was logging some parts of the requests and parameters in which content-type header was coming properly to the server.

Code:

new AjaxWrapper().asyncRequest( "<%=request.getContextPath()%>" + "/ajax/setValues.do",
{
    numberCheck: numberCheck,
    documentId: docBean.documentId,
    values: JSON.stringify( valueMap ),
    applyToF: applyToFCheckbox.checked,
    codeExternalF: (applyToFCheckbox.checked && codeExternalF.checked),
    applyToN: applyToNCheckbox.checked,
    codeExternalN: (applyToNCheckbox.checked && codeExternalN.checked)
},
{
    success: function( messageBeanJsonList, response, argument ) {
        // some code here
    },
    failure: function( messages ) {
        // some code here
    },
    after: function( messageBeanJsonList, response, argument ) {
        // some code here
    }, 
    argument: { codingPanel: mainCodingPanel, changedValues: changedValues }
},
AjaxWrapper.Methods.Post
);

Method to encode the parameters:

_encodeParameters: function(parameters) {       
    var params = new Array();

    if (parameters) {
        for(var name in parameters) {
            if (YAHOO.lang.isArray(parameters[name])) {
                for(var i=0; i<parameters[name].length; i++) {
                    params.push(encodeURIComponent(name) + "=" + encodeURIComponent(parameters[name][i]));
                }
            }
            else {
                params.push(encodeURIComponent(name) + "=" + encodeURIComponent(parameters[name]));
            }
        }
    }

    return params.join("&");
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文