jQuery 邮政编码工作但回调是错误的

问题描述

我有这个用于提交表单的 jQuery 代码

<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

enter image description here

响应为“ok”,在请求的 url 中得到回应。

enter image description here

它 100% 工作,但为什么回调是错误的?

enter image description here

有什么地方不对吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)