I would really appreciate some help with this. I tried tons of solutions as posted in this forum, but I cannot get it to work

My ajax call is something like

    var ref = $('#ref').val();
    var _token = $("input[name='_token']").val();
       method: "POST",
       date: {ref:ref, _token,_token},
       success:function (result) {
           if (result==0){
            $('.referror').html('<label class="text-danger"><i class="fa fa-exclamation-circle"></i> Invalid Sposor Id</label>');

In Route

    Route::post('/login/refcheck', '[email protected]')->name('refcheck');

And controller

    function refCheck(Request $request){
        return 0;

My login.blade.php is

        <form class="form-contact-warp form-calc-ship cb-form" method="POST" action="{{ route('register') }}">
    <input id="ref" class="form-control{{ $errors->has('ref') ? ' is-invalid' : '' }}" placeholder="Sponsor" type="text" name="ref" value="@if (request()->has('ref'))
@endif" required autocomplete="name" autofocus>
<div class="errordiv referror"></div>

I am getting this error

POST http://localhost/metazone/public/login/refcheck 419 (unknown status)

2 Answers

kerdouchi mohamed On Best Solutions

date: {ref:ref, _token:_token},

Michael Nguyen On

you have several typos. Try below

data: {ref:ref, _token:_token},

If it still give 419, do console.log(_token) to make sure your csrf token is valid