<script type="text/javascript">
? ?$(function(){
? ? ? ?$('#register').on('click',function(){
? ? ? ? ? ?//?ajax提交?戶信息
? ? ? ? ? ?$. ajax({
? ? ? ? ? ? ? ?type: 'post',
? ? ? ? ? ? ? ?url: "{:url('insert')}",
? ? ? ? ? ? ? ?data: $('#login').serialize(),
? ? ? ? ? ? ? ???? ??: 'json',
? ? ? ? ? ? ? ???: ??(???)
? ? ? ? ? ? ? ?{
? ? ? ? ? ? ? ? ? ?alert('成功了');
? ? ? ? ? ? ? ?},
? ? ? ? ? ? ? ???: ??(???)
? ? ? ?? ? ? ?{
? ? ? ? ? ? ? ? ? ?alert(data.message);
? ? ? ? ? ? ? ?}
? ? ? ? ? ?})
? ? ? ?})
? ?})
</ script>
后臺方法:
public function ?insert()
{
? ?if(Request::isAjax()){
? ? ? ?$data = Request::Exception('password_confirm','post');
? ? ? ?if (UserModel::create($data))
? ? ? ?{
? ? ? ? ? ?return ['status'=>1,'message'=>'注冊成功'];
? ? ? ?}else{
? ? ? ? ? ?return ['message'=>'操?失敗','status'=>0];
? ? ? ?}
? ?}else{
? ? ? ?$this->error('請求類型錯誤','register');
? ?}
}
?? ?? ??? ????? ??? ?? ????? ??? ??????. ??? ???? Firefox? ???? ??? ??? ???? ???????
?????? ???? ?? ?? ? ???? ?? ????. ??? ????? ?? ???? ?? ?????. ??? ????? ???? ??? ?? ??? ?????.