ajax - easyXDM PUT 将数据放入查询字符串中

标签 ajax cross-domain put easyxdm

您好,当尝试使用 easyXDM 发出 PUT 请求时,我遇到了一个非常奇怪的问题。

that.xhr.request({
                        url: url,
                        method: "PUT",
                        data: [{"foo":"test"}],
                        headers: { "Content-Type": "application/json;" }
                    }, function (response, xhr) {
                        options.success(jQuery.parseJSON(response.data));

                    },function(err) {
                        alert(err);
                    });

这不会生成请求正文消息,而是将数据视为查询字符串参数。对此有什么可以做的吗? 谢谢

最佳答案

我刚刚遇到了同样的问题并通过以下方式解决了它:

如果您使用远程站点上 easyXDM 附带的默认 index.html,则会有一行内容

var isPOST = (config.method == "POST");

将此行替换为

var isPOST = (config.method == "POST") || (config.method == "PUT");

并且数据应作为表单数据而不是查询字符串参数发送。

关于ajax - easyXDM PUT 将数据放入查询字符串中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15337476/

相关文章:

c - BerkeleyDB 不存储文件

ruby-on-rails - Rails 升级中的 PATCH 和 PUT 路线

jquery - 使用 AJAX 进行表单验证需要单击两次提交

jquery跨域ajax和getJson返回错误

python - 我可以用 python 的 SimpleHTTPServer 设置一个标题吗?

javascript - 同一台机器不同端口的Ajax跨域

rest - XPOST 和 XPUT 的区别

javascript - 无法加载资源: the server responded with a status of 500 (Internal Server Error) while returning image in base64 format from controller

php - 从 MySQL 进行表单日期验证的 AJAX 调用在页面刷新之前不会再次工作

ajax - 无需重定向的 Django 远程身份验证