Home >Backend Development >PHP Tutorial >ThinkPHP's method of processing Ajax returns

ThinkPHP's method of processing Ajax returns

不言
不言Original
2018-06-06 15:09:441641browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn