2012-04-27 5 views
1

を送信していない。jQuery.ajaxは、I)はjQuery.ajaxを(使用してフォームを送信してい1.7.2を使用しての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'); 
    } 
}); 

Iは(アヤックスを期待していた)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"); 
} 
+0

を試してみてください。 – MacMac

+0

'form.attr( 'action')'はフォームが置かれているページと同じhttpアドレスとポートを持っていますか? –

答えて

1

を試してみた...奇妙である。この

$.ajax({ 
url: form.attr('action'), 
dataType:'json', 
type:'POST', 
success:function(data){ 
console.log(data); 
}, 
error:function(jxhr){ 
console.log(jxhr.responseText); 
} 

}); 
+0

エラーが出ないので、決してjxhrオブジェクトはありません。 – urschrei

+0

[ここをクリック](http://forums.codeguru.com/showthread.php?t=474951)知っている...私はあなたにそれに応じてデモを示した – harry

関連する問題