如何获得django';使用jQuery的HTTP响应状态代码?
成功时我的服务器“return HttpResponse()”,失败时“return HttpResponse(status=400)”。 我的客户端具有以下jquery ajax功能:如何获得django';使用jQuery的HTTP响应状态代码?,jquery,ajax,django,Jquery,Ajax,Django,成功时我的服务器“return HttpResponse()”,失败时“return HttpResponse(status=400)”。 我的客户端具有以下jquery ajax功能: $('#submit').click(function(){ $.post("{% url 'addcomment' %}", {msg:$('#newcomment').val()}, function(data,status){ if (status==200) {
$('#submit').click(function(){
$.post("{% url 'addcomment' %}", {msg:$('#newcomment').val()}, function(data,status){
if (status==200) {
location.reload()
} else {
alert("Comment failed")
}
});
});
但是ajax代码不起作用。有什么想法吗?正如文档中明确指出的,成功回调将返回一个
数据
、文本状态
和jqXHR
参数
如果需要响应状态,请从第三个参数中获取它