longshengguoji 2020-02-13
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; });
结束数据方法的参数,该如何定义?-- 集合为自定义实体类中的结合属性,有几个实体类,改变下标就行了。<input id="add" type="button" value="新增visitor&quo
本文实例讲述了php+ ajax 实现的写入数据库操作。分享给大家供大家参考,具体如下:。<input class="tel" type="text" placeholder="请输入您的手机号码&q