问题描述
<div class="action-handler" id="pause-request-handler"></div>
<script>
$(document).on('submit','#pause-request',function (e) {
e.preventDefault();
var form = $(this);
var handler = $(this).attr('action');
var datastring = form.serialize();
$.ajax({
type: 'POST',url: handler,data: datastring,dataType: 'JSON',success: function(data) {
window.location.reload();
},error: function() {
$('#pause-request-handler').text('Error occurred.');
}
});
});
它按预期工作,它发送表单并添加新记录而没有错误,但回调是“错误”,因此它不会在成功时重新加载页面,而是打印发生的错误。
使用开发者工具 -> 网络 -> XHR 它给出状态代码:OK
响应为“ok”,在请求的 url 中得到回应。
它 100% 工作,但为什么回调是错误的?
有什么地方不对吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)