addCustomer($this->admin["id"]))"..."/> addCustomer($this->admin["id"]))"...">
Home > Article > PHP Framework > Usage example of ajaxReturn in thinkphp
The following is the thinkphp framework tutorial column to introduce the usage of ajaxReturn in thinkphp. I hope it will be helpful to friends in need!
1. Example:
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. Return data:
$data
3.Receive data.
For example:
$.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(); } } });
The above is the detailed content of Usage example of ajaxReturn in thinkphp. For more information, please follow other related articles on the PHP Chinese website!