error 401 ajax in laravel already added token -
i stuck in laravel 5.4 ajax because says error 401. unauthorized
i searched solutions , made this:
from header:
<meta name="csrf-token" content="{{ csrf_token() }}">
and in ajax:
<script type = "text/javascript"> $.ajaxsetup({ headers: { 'x-csrf-token': $('meta[name="csrf-token"]').attr('content') } }); function getproducts(category_id) { $("#product-list").empty(); $.ajax({ url:"{{ url('home/product') }}/" +category_id, type:"get", datatype: "json", success: function(data) { } }); } </script>
nothing happens. . don't know why
any suggestions please?
Comments
Post a Comment