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 -

Python Tornado package error when running server -

Qt QGraphicsScene is not accessable from QGraphicsView (on Qt 5.6.1) -