我的ajax上的error
附加了一个函数但它不会显示500条响应代码的错误消息吗?我用xhr.responseText
显示错误消息,但它返回一个空字符串,有人可以告诉我为什么吗?
$.ajax({
type: "PUT",
url: "/ajax/account/create_key",
data: { key_id: document.getElementById('account-key-value').value, expires_at: document.getElementById('account-key-expires').value },
success: function(result) {
// close modal
swal({
title: "That was a success!",
text: 'Your account key has been created.',
icon: "success",
button: "Okay!",
});
document.getElementById('account-keys-content').innerHTML = result;
},
error: function(xhr, ajaxOptions, thrownError) {
if(xhr.status == 400) {
swal({
title: "Opps!",
text: xhr.responseText,
icon: "error",
button: "Okay!",
});
}
else {
swal({
title: "Opps, something went wrong!",
text: xhr.responseText,
icon: "error",
button: "Okay!",
});
}
}
});