When I tried to log in using ajax first time with wrong credentials it hits the API but then again tried with right credentials show 419 error
Here is the code:-
$(document).on('submit', '#userLogin', function(e) {
e.preventDefault();
$('.s-login').html('Please wait...');
$('.s-login').attr('disabled',true)
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$.ajax({
type: 'post',
url: $(this).attr('action'),
data: $(this).serialize(),
dataType: "json"
})
.done(function(data) {
if(data.status==200){
toastr.success(data.message,"Status",{
timeOut: 5000,
"closeButton": true,
"debug": false,
"newestOnTop": true,
"positionClass": "toast-top-right",
"preventDuplicates": true,
"tapToDismiss": true
});
}
});
});
Tried to refresh the token also but sometimes it works and sometimes doesn't. Any ideas would be appreciated. Thank You !!
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3c8A3sQ
via IFTTT
Aucun commentaire:
Enregistrer un commentaire