Ask: Why can't the ajax submitted data be transmitted to the controller?
清晨的粥
清晨的粥 2019-09-18 14:26:09
0
3
1197

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

清晨的粥
清晨的粥

reply all(2)
卢小强

Why should data be login and not form?

  • reply The id of the form is login
    清晨的粥 author 2019-09-20 08:22:56
每天至少八杯水

So long

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!