2013-04-25 29 views
1

當我遇到困難時,我的服務器「返回HttpResponse()」,失敗時返回「HttpResponse(status = 400)」。 我的客戶有以下的jQuery AJAX功能:如何使用jQuery獲取django的HttpResponse狀態碼?

$('#submit').click(function(){ 
    $.post("{% url 'addcomment' %}", {msg:$('#newcomment').val()}, function(data,status){ 
     if (status==200) { 
      location.reload() 
     } else { 
      alert("Comment failed") 
     } 
    }); 
}); 

但AJAX代碼不起作用。任何想法?

+0

的可能重複[如何從jQuery.ajax獲取響應狀態代碼?](http://stackoverflow.com/questions/5344145/how-to-get-response-status-code-from-jquery-ajax) – 2013-04-25 08:47:23

回答

相關問題