首页 > ajax回调重置表单没效果

ajax回调重置表单没效果

如下代码,init()在初始化页面时复选框单选框都有效果,放到ajax的回调函数怎么没效果?

        $.ajax({
             type: "POST",
             url: "do/createBill",
             data: JSON.stringify(data),
             dataType: "json",
             contentType:"application/json",
             success: function(data){
                        swal("Success!!!", "You created a Bill!", "success");
                        init();
                      },
             error: function(e) {
                 swal("Error!!!", "输入有误,请检查!!!", "error");
             }
         });
    });
    
    function init() {
        $("#content").val("");
        $("#amount").val("");
        $('input[name="stackholder"]').attr("checked",true);
        $("input[name='payer']:eq(0)").attr("checked",true);
        var billTime = document.getElementById('billTime');
        billTime.value = getNowFormatDate();
    }
    init();

你都提交给服务器了,服务器成功返回后的处理方式你应该以回调函数的方式进行。


可以先看看浏览器开发者工具里的 network,确认请求的发送和返回正常与否。然后再说后续。

【热门文章】
【热门文章】