我为这个愚蠢的问题道歉,但我需要你的帮助。我需要获取有关内部响应的信息AJAX
.
$.ajax({
type: "POST",
url: '/register',
data : registerRequestJSON,
contentType:"application/json",
success: function(data){
$("#register_area").text();// need to show success
},
error: function(err) {
$("#register_area").text("@text"); // @text = response error, it is will be errors: 324, 500, 404 or anythings else
}
});
如何使用响应主体? (文档 Jquery.Ajax http://api.jquery.com/jQuery.ajax/目前不工作)
错误处理程序的第一个参数是jqxhr
,它有以下性质responseText
这将给出响应主体。
$.ajax({
type: "POST",
url: '/register',
data : registerRequestJSON,
contentType:"application/json",
success: function(data){
$("#register_area").text();// need to show success
},
error: function(jqxhr) {
$("#register_area").text(jqxhr.responseText); // @text = response error, it is will be errors: 324, 500, 404 or anythings else
}
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)