Ajax 删除返回 200 但触发错误事件 [英] Ajax delete returns 200 but firing off error event
本文介绍了Ajax 删除返回 200 但触发错误事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经阅读了大量已发布的帖子,但似乎没有一个涉及删除.我的代码返回 200 状态,但触发错误事件...
I have read through loads of posted threads and none seem to deal with delete. My code is returning a 200 status yet fires of the error event...
$.ajax({
type: 'DELETE',
url: '/' + type + '/' + name,
success: function() {
window.alert(type + " " + name + " successful");
},
error: function(xhr, status) {
alert(xhr.status);
alert('Failed to delete ' + type + ' ' + name)
}
});
推荐答案
问题是没有定义 dataType.我添加了 dataType: 'text' 并解决了我的问题.
The problem was that there was no dataType defined. I added dataType: 'text' and I resolved my problem.
这篇关于Ajax 删除返回 200 但触发错误事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文