YUI asyncRequest:缺少 POST 参数
我正在使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论