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 -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -