使用1.7.2,我提交使用jQuery.ajax()形式:)jQuery.ajax不發送一個XMLHttpRequest頭
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');
}
});
我期待的阿賈克斯(呼叫設置了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");
}
那......是怪異。 – MacMac 2012-04-27 11:05:12
'form.attr('action')'與表單放置的頁面具有相同的http地址和端口嗎? – 2012-04-27 11:54:16