Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

laravel post ajax proper csrf

$.ajax({
    url: '/postAjaxUrl',
    type: 'POST',
    dataType: 'json',
    data: {user_id: 10},
    success: function(response) { 
        console.log(response);                              
    },
    beforeSend: function (request) {                    
        return request.setRequestHeader('X-CSRF-Token', $("meta[name='csrf-token']").attr('content'));
    }
 });
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #laravel #post #ajax #proper #csrf
ADD COMMENT
Topic
Name
5+1 =