addCustomer($this->admin["id"]))"..."/> addCustomer($this->admin["id"]))"...">

Home  >  Article  >  PHP Framework  >  Usage example of ajaxReturn in thinkphp

Usage example of ajaxReturn in thinkphp

藏色散人
藏色散人forward
2020-12-04 17:18:107971browse

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!

Usage example of ajaxReturn in thinkphp

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 : "",
                    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!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete