php - Laravel ajax form validation -


i want send short form email ajax.

code below adds hidden input name='_token'

{!! form::open(['route'=>'registercheck', 'id'=>'register_form', 'novalidate'=>'novalidate']) !!} 

in js script add data request:

$.ajax({     method:'post',     url: $form.attr('action'),     data:{         '_token': $form.find('[name="_token"]').val(),         email: $('#email').val(),         user: $this.attr('id'),     } })   

how can authenticate , namespaces should include this?

first add meta

<meta name="csrf-token" content="{{ csrf_token() }}" /> 

then in script add

var csrf_token = $('meta[name="csrf-token"]').attr('content'); 

finally change request this

$.ajax({ method:'post', url: $form.attr('action'), data:{     _token: csrf_token,     email: $('#email').val(),     user: $this.attr('id'),    } })   

Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -