Answers for "can we send data with the help of ajax without csrf in laravel"

2

pass csrf token in ajax laravel

$.ajax({
                    headers: {
                            'X-CSRF-TOKEN': "{{csrf_token()}}",
                        },
                    url : "{{route('')}}",
                    type : "GET",
                    success : function(response){
                        
                    }
                });
Posted by: Guest on March-30-2022
1

laravel jquery ajax post csrf

<script>
 $(document).ready(function() {
    $(document).on('click', '#ajax', function () {
      $.ajax({
         type:'POST',
         url:'/ajax',
         headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
         success:function(data){
            $("#msg").html(data.msg);
         }
      });
    });
});
</script>
Posted by: Guest on March-25-2022

Code answers related to "can we send data with the help of ajax without csrf in laravel"

Code answers related to "Javascript"

Browse Popular Code Answers by Language