【发布时间】:2012-08-21 09:31:24
【问题描述】:
我正在测试一些 csrf 的东西,我想知道是否可以使用 Content-Type: application/json 发布跨域 ajax 请求
每次我尝试用 jQuery 来做这件事时:
$.ajax({
type: "post",
url: "http://someotherdomain.com/endpoint",
contentType: "application/json; charset=UTF-8",
data: {"a": "1"},
dataType: "json",
crossDomain: true,
success: function(data){ alert(data); },
failure: function(data){ alert(data); }
});
我总是发送 HTTP OPTIONS 请求而不是 HTTP POST。
注意-我不关心接收数据,我只需要一个单向的帖子。
注意 - 内容类型不能是 x-www-form-urlencoded 也不能是 GET 请求。
【问题讨论】:
标签: jquery http cross-domain csrf cors