为 Struts2 将 dojo.xhrGet 转换为 dojo/request/xhr
Converting dojo.xhrGet to dojo/request/xhr for Struts2
我有以下代码将 code
和 objectIds
正确传递给 trailDesignations.action
。
UpdateTrailDesignationGridClass = function(){
this.updateTrailDesignationGrid = function(){
var value1 = 35;
var xhrArgs = {
url: "/trails/trailDesignations.action",
handleAs: "text",
preventCache: true,
content: {
code: value1,
objectIds: "35.36"
},
load: function(data){
featureResultsContent.innerHTML = data;
},
error: function(error){
featureResultsContent.innerHTML = "An unexpected error occurred: " + error;
}
};
// Call the asynchronous xhrGet
var deferred = dojo.xhrGet(xhrArgs);
};
};
但是由于 xhrGet
已被弃用,我正在尝试使用以下代码对 dojo/request/xhr
做同样的事情。
UpdateTrailDesignationGridClass = function(){
this.updateTrailDesignationGrid = function(){
var value1 = 35;
xhr("/trails/trailDesignations.action",{
data:{
code: value1,
objectIds: "35.36"
},
preventCache: true
}).then(function(data){
featureResultsContent.innerHTML = data;
},function(err){
featureResultsContent.innerHTML = "An unexpected error occurred: " + error;
});
};
};
使用新代码,数据不会传递到 code
和 objectIds
字段。我在这两种情况下都使用了相同的 Struts 操作。
<action name="trailDesignations" class="gov.mo.dnr.tis.map.TrailDesignations">
<result name="success" type="stream">
<param name="contentType">text/html</param>
<param name="inputName">inputStream</param>
</result>
</action>
我确实从 trailDesignations.action
那里得到了信息。
您需要使用查询 :{} 来传递负载...您可以找到文档@http://dojotoolkit.org/reference-guide/1.10/dojo/request/xhr.html
对于 post 请求数据:可以使用 {}。
xhr("/trails/trailDesignations.action",{
query:{
code: value1,
objectIds: "35.36"
},
preventCache: true
}).then(function(data){
featureResultsContent.innerHTML = data;
},function(err){
featureResultsContent.innerHTML = "An unexpected error occurred: " + error;
});
我有以下代码将 code
和 objectIds
正确传递给 trailDesignations.action
。
UpdateTrailDesignationGridClass = function(){
this.updateTrailDesignationGrid = function(){
var value1 = 35;
var xhrArgs = {
url: "/trails/trailDesignations.action",
handleAs: "text",
preventCache: true,
content: {
code: value1,
objectIds: "35.36"
},
load: function(data){
featureResultsContent.innerHTML = data;
},
error: function(error){
featureResultsContent.innerHTML = "An unexpected error occurred: " + error;
}
};
// Call the asynchronous xhrGet
var deferred = dojo.xhrGet(xhrArgs);
};
};
但是由于 xhrGet
已被弃用,我正在尝试使用以下代码对 dojo/request/xhr
做同样的事情。
UpdateTrailDesignationGridClass = function(){
this.updateTrailDesignationGrid = function(){
var value1 = 35;
xhr("/trails/trailDesignations.action",{
data:{
code: value1,
objectIds: "35.36"
},
preventCache: true
}).then(function(data){
featureResultsContent.innerHTML = data;
},function(err){
featureResultsContent.innerHTML = "An unexpected error occurred: " + error;
});
};
};
使用新代码,数据不会传递到 code
和 objectIds
字段。我在这两种情况下都使用了相同的 Struts 操作。
<action name="trailDesignations" class="gov.mo.dnr.tis.map.TrailDesignations">
<result name="success" type="stream">
<param name="contentType">text/html</param>
<param name="inputName">inputStream</param>
</result>
</action>
我确实从 trailDesignations.action
那里得到了信息。
您需要使用查询 :{} 来传递负载...您可以找到文档@http://dojotoolkit.org/reference-guide/1.10/dojo/request/xhr.html 对于 post 请求数据:可以使用 {}。
xhr("/trails/trailDesignations.action",{
query:{
code: value1,
objectIds: "35.36"
},
preventCache: true
}).then(function(data){
featureResultsContent.innerHTML = data;
},function(err){
featureResultsContent.innerHTML = "An unexpected error occurred: " + error;
});