小弟有一个需求,添加一个用户,返回了受影响行数,我在service里做了判断if(lines == 1 ) {return "addCustomer_success";}else {return "addCustomer_error";}现在的问题是怎么在前台取到值并进行判断?如果return的是addCustomer_success就弹窗添加成功,返回的是addCustomer_error的话就弹窗添加失败。
1 回答
森栏
TA贡献1810条经验 获得超5个赞
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | //小面为jQuery的ajax请求url是你后台controller的路径,type是controoler的请求方式, //data传递的参数如{name:"张三"},success就是执行成功后执行的方法,其中的data就是 //你的返回值 $.ajax({ url: "xxx/xxx", type: "xxx", data: {}, success: function (data) { if (data.code =="addCustomer_success") { alert("添加成功") } else { alert("添加失败") } } }) |
- 1 回答
- 0 关注
- 945 浏览
添加回答
举报
0/150
提交
取消