I failed to follow the teacher's instructions
白月光 °
白月光 ° 2018-03-27 22:40:17
0
9
1594

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');

if(UserModel::create($data)){

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

白月光 °
白月光 °

reply all(6)
呼啦啦下雨天

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.

  • reply Brother, how did you write it? I followed the video but failed. I couldn't insert data into the database.
    鱼越龙门 author 2018-12-18 22:48:04
JonnyZhu

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

 Jensen

Hello, I have the same problem, how can I solve it?

plhxz

Have you succeeded now? I have the same problem

路过
  1. Make sure you have introduced jquery

  2. Make sure ajax has passed the data

  3. Background php receives data

  4. There are databases, tables, and fields corresponding to the data you added

    I can only help you so far

  • reply It is confirmed that jquery is introduced, data is transmitted through ajax, and the data transmitted by ajax is received in the background. However, the create function neither reports an error nor succeeds, and there is no response.
    白月光 ° author 2018-03-28 14:46:44
  • reply Did you succeed? I also encountered this problem. Alas.
    凌晨¤ author 2018-08-01 14:14:16
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!