post - dojo.xhrPost 的参数

标签 post dojo get parameter-passing

当我使用 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/

相关文章:

java - 使用 POSTMAN 在 saiku 中点击查询 EXECUTE API 时出错

php - 使用PHP提交表单后将数据传递到另一个页面

json - 将 JSON 从数据框上传到 firebase

themes - 如何预览Dojo/Dijit主题?

javascript - 使用 complexQuery 的 Dojo DataGrid 过滤不起作用

php - 如何在我的示例中使用 urlencode()?

python - 在瓶中渲染来自请求的图像

javascript - 一个模块 : OPTIMIZER FAILED: InternalError: missing name after . 运算符(operator)的 Dojo 构建失败

javascript - GET 到 POST 不工作

php - 根据 id 和复选框更新记录