Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Ober4You's avatar

I just can't get around this....i also get an error TokenMissmatchException but not right away...

the ajax request works until the csrf token is changed....laravel does this automatically. i mean changing the token. This is my code:

$(document).ready(function() {
    $(document).on('input paste', '#soap', function () {
          $.ajax({
             type:'POST',
             url:'/soap',
             headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
             data: $('#countryCode, #soap').serialize(),
                 success:function(data){
                    $('input[id=msg]').val(data.msg);
                 }
            });
    });
});

What am i doing wrong...why do i get wrong token...it's like it uses the same token every time?

Ober4You's avatar

I restarted my browser and now all is fine :(

1 like
Previous

Please or to participate in this conversation.