当我使用 dojo.xhrGet
时,我使用这种方式通过 GET
dojo.xhrGet
({
url:"MyServerPageURL?Param_A="+"ValueA"+"&Param_2="+"Value2",
load: function(data)
{
//do something
},
preventCache: true,
sync: true,
error: function(err)
{
alert("error="+err);
}
});
当我不得不使用 dojo.xhrPost
时,我怎么能做类似的事情(发送多个参数)?
最佳答案
你不想使用 postData 参数,除非你想发送一个原始的 POST 字符串。您通常希望使用“内容”参数。例如:
dojo.xhrPost({
url: 'http://whatever...',
contents: {
ParamA: 'valueA',
ParamB: 'valueB'
},
load: function(response) {
// ...
}
});
注意:使用“内容”也适用于 xhrGet,无需自己构建查询字符串并附加到 URL。
关于post - dojo.xhrPost 的参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5746332/