当我用ajax调用这个jquery函数获取this error时
[对象]
$('a#room_no').click(function() {
var roomNumber = $(this).text();
alert(roomNumber);
var href = $(".room_check_out_form").attr('href');
$.ajax({
type: "POST",
url: href,
data: {
roomNumber: roomNumber
},
dataType: "JSON",
success: function(data) {
console.log(data);
alert(data.roomNumber)
},
error: function(err) {
alert(err);
}
});
});
在你的error
处理程序中,err
是一个对象;警报(错误)导致'[object Object]'显示在警告对话框中。
将错误处理程序更改为此类应将更多有用信息记录到控制台。检查err
对象的属性:
error: function(err) {
console.log(err);
console.log(err.responseText);
alert(err.responseText);
}