close
easy, When laravel form post method will need token...
so,
laravel TokenMismatchException in ajax request
You have to insert a hidden input with the _token and later get that value as you do to get the other form fields in your ajax post.
<inputtype="hidden"name="_token"value="{{ csrf_token() }}"/>
An another method,
On your view you can set an object with the _token
<scripttype="text/javascript">var _globalObj ={{ json_encode(array('_token'=> csrf_token()))}}</script>
and later on your ajax call you can get the _token from the object like this:
var token = _globalObj._token;
and include it on your ajax post.
就是要加token...
文章標籤
全站熱搜