我有下面的代码,它将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
那里得到了信息。
1条答案
按热度按时间bvuwiixz1#
您需要使用query:{}来传递有效负载...您可以在文档@http://dojotoolkit.org/reference-guide/1.10/dojo/request/xhr.html中找到请求后数据:可以使用{}。