xhrPost 似乎正在修改导致 404 或 405 的 URL。这是来自自定义小部件并尝试转到 WebSphere Liberty 服务器上的 REST 服务。
当使用 RESTClient 并手动构建请求时,其余服务会正确响应。
我正在使用 var jsonData = JSON.stringify(domForm.toObject("TaskTemplate")); 所以我可以验证数据是否正确并将数据作为该字符串发送:数据:jsonData,
URL 在表单中是硬编码的,当前没有使用替换:
<form id="TaskTemplate" name="TaskTemplate"
data-dojo-attach-point="taskTemplateNode"
method="POST"
action="http://localhost:9080/test2/rm/tasks/64/update">
我还有一个 URL 为“ http://localhost:9080/test2/rm/tasks/64/ ”的 GET,它工作正常。似乎与 PUT 或 POST 相关联...
当我执行 xhrPost 时,出现以下错误:“NetworkError: 404 Not Found - http://localhost:9080/test2/undefined ”
由于看到了“未定义”,就好像 xhrPost 在硬编码 URL 中进行了一些替换......我正在使用 Rational Application Developer 附带的 1.9.2-20140219-IBM 版本的 dojo。我已经尝试过 xhrPost 和 xhrPut ,结果相同。
这是按下按钮时调用的方法:
applySubmit: function() {
console.log("inside applySubmit");
var jsonData = JSON.stringify(domForm.toObject("TaskTemplate"));
console.log(jsonData);
var xhrArgs = {
// url: "http://localhost:9080/test2/rm/tasks/64/update",
data: jsonData,
preventCache: true,
timeout: 10000,
handleAs: "text",
contentType: "application/json",
load: function(data) {
console.debug("applySubmit success:" + data);
},
error: function(data) {
console.debug("applySubmit error:");
}
};
console.log("doing dojo.xhrPxxx(xhrArgs);");
var deferred = dojo.xhrPost(xhrArgs); // any need to save local var and exit?
}
在服务器日志中,我看到 [WARNING] SRVE0190E: File not found: /undefined 并且来自 webcontainer(考虑到上面的错误消息,这是有道理的)所以,这意味着它与我的休息服务无关,永远不会得到给它。
这真的开始延迟我们的项目,所以任何关于为什么会发生这种情况的想法将不胜感激!