ajax - how to get django's HttpResponse status code with jQuery? -


my server "return httpresponse()" when succuess, "return httpresponse(status=400)" when failed. client has following jquery ajax function:

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

but ajax code doesn't work. idea?

as documentation states, success callback returns data, textstatus , jqxhr argument

http://api.jquery.com/jquery.post/#jquery-post-url-data-successdata--textstatus--jqxhr-datatype

if want response status third argument jqxhr.status


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -