ThinkPHP5 ajax submits form operation instance analysis, thinkphp5ajax
This document describes how to submit a form using thinkPHP5 ajax. We will share this with you for your reference. The details are as follows:
<! DOCTYPE html>
In fact, there is no difference with normal ajax, mainly because jquery'sserialize()Method serialization form
I encountered some trouble in the middle, that is, I am not familiar with the thinkphp5 framework. I have been using 3.2.3 before, but the differences between the two versions are still there.
One is $ _ POST, and the other is that the original ajax url can be used to use the U method of the Framework. Instead, I looked at the Helper function under think and found that it is a url.
Below is a method that is used to return json data.
Public function test ($ mess, $ id) {if ($ mess = '000000') {return json ("ajax successful! ". $ Mess. "---". $ id) ;}else {return json ("You output other values :". $ mess. "---". $ id );}}
In addition, the common parameter submission and processing methods are as follows:
Input parameters in Form submission:
<input type="hidden" name="project_name" value="$project_name"/>
Get In Controller
$project_name=input("post.project_name");
Jump parameters in php:
$ This-> success ('Project added successfully', url ("Version/index", array ('Project _ name' => $ project_name); die;