register.html file
<script>
$(function () {
$("#register").on('click',function () {
// Alert ($ ('#login'). Serialize ());
$ .ajax ({
Type: 'Post',
URL: "{: URL ('Index/User/Insert ')}",
using using using use using ‐ ‐ ‐ ‐ ‐ ‐ ‐ ‐ dataType:'json',
' ;
##{
if(Request::isAjax()){
//Use the model to create data
//Get the data submitted by the user through expression
$data = Request::except('password_confirm','post');
return ['status' => 1,'message'=>'Register Success'];
}else{ return ['status' => 0,'message' =>'Registration failed'];
using using using using using using using through out through out out out out out out out of ''''''‐to ‐‐‐‐‐‐‐‐‐‐ ->error("Request type error",'register');
}
}
May I ask the teacher why there is no response when submitting, and the database is not successfully added
呼啦啦下雨天2019-06-11 08:52:44
You can directly reference think/Db in User.php and use Db to insert data
时光2018-09-30 22:01:07
My problem is the same as yours. I just changed the ajax submitted path {url('insert')} to an absolute path. I don't know why.
JonnyZhu2018-08-10 16:19:54
data: $('#login').serializeArray(), details the serializeArray() method to serialize form elements (similar to the .serialize() method) and return JSON data structure data. Note: This method returns a JSON object rather than a JSON string. The website is here: http://www.w3school.com.cn/jquery/ajax_serializearray.asp
路过2018-03-28 08:22:06
Make sure you have introduced jquery
Make sure ajax has passed the data
Background php receives data
There are databases, tables, and fields corresponding to the data you added
I can only help you so far