Permintaan mendesak untuk permintaan ajax tp5 Data tidak boleh ditambah ke pangkalan data.
phpcn_u102592
phpcn_u102592 2018-04-08 20:17:33
0
1
2566
. this->fetch();



}

public function insert()
{
                                                                                                                                                                                                                                                                                                                                                                                  untuk ($data)){
              gunakan 's ' ‐ ‐ ‐ ‐ ‐ ‐ ‐ ‐ ‐ ‐ ‐ return ['status'=>1, 'message'=>'Tahniah, pendaftaran berjaya! ']; E} lain {
Kembalikan [' Status' = & GT; '];
                                                                                                                                                                                                                                 }




<!DOCTYPE html>
<html lang="en">
<head>
<meta title="gt;
" <F meta Tajuk</title>
<link rel="stylesheet" href=" /static/css/bootstrap.css"/>
<script src="/static/js/jquery-3.3.1.min.js "></script>
<script src="/static /js/bootstrap.js"></script>
</head>
<body>

<form class=" form-horizontal" method="post" id="testPost">
<div class="form-group">
" " <label for="inputEmail3" class="col-sm-2 control- label">E-mel</label>
" " <div class="col-sm -10">
                                                                                                                                                                                                                                                      ...;
   <div class="form-group">
       <label for="inputPassword3" class="col-sm-2 control-label">Kata Laluan</label>
       <div class="col-sm-2 control-label" -sm-10">
           <input type="password" name="password" class="form-control" id="inputPassword3" placeholder="Kata Laluan">
       </div>  </div> div>
   <div class="form-group">
       <label for="inputPassword3" class="col-sm-2 control-label">Kata Laluan</label>
  ; div  =" col-sm-10">
           <input type="password" name="password_confirm" class="form-control" id="inputPassword4" placeholder="Password_confirm">
       </
</div /div>

   <div class="form-group">
       <div class="col-sm-offset-2 col-sm-10"> "btn btn-default" id="testButton">Log masuk</button>
       </div>
   </div>
</form>
< {fungsi>
<) $("#testButton").on('click',function () {
           $.ajax({
               type:'post',
url:"{:url('insert')}",
data: $ ('#testPost').serialize(),
dataType: 'json',
success: function (data) {
                   alert('成功了');

}  } )      } )              } )       
   })



</script>

</body>
</html>

phpcn_u102592
phpcn_u102592

membalas semua(1)
豆芽

Tambah gunakan thinkRequest di bahagian atas

Selain itu, kaedah insert() perlu memasukkan parameter, insert(Requset $request)

{

  $data = $request->param();

}

Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan