php入门到就业线上直播课:进入学习
Apipost = Postman + Swagger + Mock + Jmeter 超好用的API调试工具:点击使用
1.例子:
if ($codeid = $model->addCustomer($this->admin["id"])) {$data["code"] = 10000;$data["message"] = "添加客户成功。客户编号为:{$codeid}";$data["data"] = 0;$this->ajaxReturn($data);} else {$data["code"] = 10001;$data["message"] = $model->failAddCustomer();$data["data"] = 0;$this->ajaxReturn($data);}
登录后复制
2.返回数据:
$data
3.接收数据。
例如:
$.ajax({type : "POST",url : "<?php echo U('policy/addCustomer'); ?>",dataType : "JSON",data : data,success : function(eve){alert(eve.message);if (eve.code == 10000){window.location.reload();}}});
登录后复制
以上就是thinkphp中ajaxReturn的用法示例的详细内容,更多请关注php中文网其它相关文章!