Mozilla的自己specification说简单GET
或POST
应该是本地CORS的无预检但到目前为止一切POST
尝试我做已经导致了OPTIONS
头走出去。当我将其从POST
更改为代码立即发送一个适当的GET
请求,以便跨网站部分工作正常。为什么CORS似乎不适用于POST?
下面是我在做什么在Firefox中精简下来的样品:
var destinationUrl = 'http://imaginarydevelopment.com/postURL';
var invocation = new XMLHttpRequest();
if (invocation) {
invocation.open('POST', destinationUrl, true);
//tried with and without this line
//invocation.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
invocation.onreadystatechange = (function Handler() {
if (invocation.readyState == 4)
alert('Request made');
});
invocation.send(/* tried with and without data*/);
}
这里是我已经在Chrome和IE工作:
var destinationUrl = 'http://imaginarydevelopment.com/postURL';
var destination = { url: destinationUrl, type: 'POST', success: AjaxSuccess, error: AjaxError,
dataType: 'text', contentType: 'application/x-www-form-urlencoded'
};
destination.data = { 'rows': rowList, 'token': token };
$jq.ajax(destination);