}
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>
Tambah gunakan thinkRequest di bahagian atas
Selain itu, kaedah insert() perlu memasukkan parameter, insert(Requset $request)
{
$data = $request->param();
}