This article mainly introduces the method of processing Ajax return in ThinkPHP. It briefly describes the usage of Ajax in ThinkPHP and the corresponding method of processing Ajax return value. It has good practical value. Friends who need it can refer to it
The example in this article describes the way ThinkPHP handles Ajax returns, and shares it with you for your reference. The specific implementation method is as follows:
In ThinkPHP, you can directly use ajax to return:
Copy code The code is as follows:
$.post(handleUrl,{username:username.val(),content:content.val()},function(data) { //这里是接收返回来的内容。},'json');
While processing You can use this function during the process:
Copy code The code is as follows:
$this->ajaxReturn(要返回的内容,'json(json格式返回)');
Related recommendations:
ThinkPHP controller Solution to the problem that the javascript code cannot be executed
The above is the detailed content of ThinkPHP's method of processing Ajax returns. For more information, please follow other related articles on the PHP Chinese website!