search

Home  >  Q&A  >  body text

Ask: Why can't the ajax submitted data be transmitted to the controller?

I was studying "The latest ThinkPHP 5.1 world premiere video tutorial (60 days to become a PHP expert online ** class)" by teacher Peter.zhu


, in section "10-3 Preliminary Implementation of User Registration Function", why can't my ajax submission data be passed to the controller?


register.html code is:


##{include file="public:header" /}


{include file=&quo;




    <div class="form-group">


    <label for="inputEmail4" class="col-sm-2 control-label">密码:</label>


    <div class="col-sm-10">


      <input type="password" name="password" class="form-control" id="inputEmail4" 


placeholder="Password">


#%;




#<script type="text/javascript">


$(function(){


$('#register').on('click',function(){


//Submit user information using ajax


$.ajax({


type: 'post',


## url: "{:url('insert')}",

#%2

echo "<script type='text/javascript'>alert('insert was executed');</script>";


// echo "dfsdfsdf";


if(Request::isAjax()){


// Verify data


// $this->error("Request type error",'register');


$ data = Request::post();//Get the data to be verified


$rule = 'app\common\validate\User';//Customized

清晨的粥清晨的粥1893 days ago1218

reply all(3)I'll reply

  • 卢小强

    卢小强2019-09-19 15:52:06

    Why should data be login and not form?

    reply
    0
  • 清晨的粥

    The id of the form is login

    清晨的粥 · 2019-09-20 08:22:56
  • k

    k2019-09-18 15:22:24

    So long

    reply
    0
  • Cancelreply