使用 1.7.2,我使用 jQuery.ajax() 提交表单:
jQuery.ajax({
url: form.attr('action'),
action: 'POST',
dataType: 'json',
data: {post_id: id},
success: function(data) {
console.log('hurrah!');
},
error: function() {
console.log('whoops');
}
});
我期待 .ajax() 调用来设置 XMLHTTPRequest 标头,但它不是:
Referer: http://0.0.0.0:5000/messages/news-feed
Origin: http://0.0.0.0:5000
Content-Length: 42
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.18.5 (KHTML, like Gecko) Version/5.2 Safari/535.18.5
Connection: keep-alive
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
我尝试将headers
设置添加到通话中,但没有任何区别;标题没有被设置:"X-Requested-With":"XMLHttpRequest"
我也试过
beforeSend: function (request) {
request.setRequestHeader("X-Requested-With", "XMLHttpRequest");
}