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

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -