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
You can directly reference think/Db in User.php and use Db to insert data
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.
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
Hello, I have the same problem, how can I solve it?
Have you succeeded now? I have the same problem
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