Home>Article>PHP Framework> thinkPHP5 ajax form submission operation example analysis
The example in this article describes the thinkPHP5 ajax form submission operation. Share it with everyone for your reference, the details are as follows:
In fact, it is no different from normal ajax. It mainly uses jquery’sserialize()
method to serialize the form
In the middle I encountered some troubles because I am not familiar with the thinkphp5 framework. I have not had time to use 3.2.3 before. There are still some differences between the two versions.
One is that $_POST cannot be used, and the original ajax url can be used. The U method of the framework is gone. I looked specifically at the assistant function under think and found that it is url
Below is a random method written to return json data
public function test($mess,$id){ if($mess == '123'){ return json("ajax成功!".$mess."---".$id); }else{ return json("你输出的是其他值:".$mess."---".$id); } }
In addition, the regular parameter submission and The processing method is as follows:
Form submission and passing parameters:
Obtain
$project_name=input("post.project_name");
in the controller and jump to the passing parameters in php:
$this->success('新增项目成功',url("Version/index",array('project_name'=>$project_name))); die;
Related learning recommendations:thinkphp
The above is the detailed content of thinkPHP5 ajax form submission operation example analysis. For more information, please follow other related articles on the PHP Chinese website!