What is the difference between ECHO and return in returning AJAX results?
$.ajax ({ ... Success:function (data) { AddType = "Change"; var obj = json.parse (data); Console.log (data); } })
$addID = $this->input->post (' Addid '); $data = $this->address_model->getaddresslistinfo ($addID); (1) Echo Json_encode ($data); (2) return Json_encode ($data);
With echo on it, you can't use return! Solving
Reply content:
Echo: For output results
Return: Returning processing results
No output results, JS how to receive?
Return is the value returned in the function to facilitate subsequent calls
Definitely not.
Return is the execution result set of the returned method, and there is no output
Echo is the output of this JSON
Ajax JSON objects need to get the parsed output string
The simple truth is that you're a JSON parsing machine, your code runs out and then you return, and the rover doesn't show anything.
, only the output of the results, your eyes can see you guess can parse
Return is not returned to JS ...
You think about the PHP language function, return value returned to JavaScript ...
It reminds me of a new guy who used to throw PHP exceptions to the browser ...
return
is to return the result to the PHP program.
echo
is the AJAX response.
echo indicates the output to the requester, and return indicates that the return value does not output the result to the caller. Ajax is based on the value of the page to get the data.
The above is a detailed explanation of the Echo and return in PHP code examples of the content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!