LayUI form表单提交之ajax请求后不执行回调方法

form表单通过ajax异步提交实现新增员工的功能时,发现请求是成功的,后台也新增了该员工,却不执行回调方法(success、error),如下所示:

form.on('submit(addStaffFilter)', function(data){
                    $.ajax({
                        url:ctx+"/backend/staffManagement/addStaff",
                        type:"post",
                        contentType: 'application/json',
                        dataType:"json",                        
                        data:JSON.stringify({"staffName":$("#staffName").val(),"mobilePhone":$("#mobilePhone").val(),"idNumber":$("#idNumber").val(),"areaId":areaId,"departmentId":departmentId,"email":$("#email").val()}),
                        success:function (data) {
                            console.log("1111111111111");
                        },
                        error:function (data) {
                            console.log("22222222222222");
                        }
                    });

 问题解决:

//缺少这一句
return false;

完整js代码:

form.on('submit(addStaffFilter)', function(data){
                    $.ajax({
                        url:ctx+"/backend/staffManagement/addStaff",
                        type:"post",
                        contentType: 'application/json',
                        dataType:"json",                        
                        data:JSON.stringify({"staffName":$("#staffName").val(),"mobilePhone":$("#mobilePhone").val(),"idNumber":$("#idNumber").val(),"areaId":areaId,"departmentId":departmentId,"email":$("#email").val()}),
                        success:function (data) {
                            console.log("1111111111111");
                        },
                        error:function (data) {
                            console.log("22222222222222");
                        }
                    });
                return false;
                });

相关推荐