@tykus
... my issue was solved with your solution and other friends. It's great and thanks alot.
According to your recommendation I tried "fetch Api" but could not get right result and I get status code 419 instead of 422. because of I'm sending CSRF code, It seems there are some problems about sending this code.
my front code is like below:
const fields = {
user_index: document.getElementById('user-name').value.trim(),
password: document.getElementById('password').value.trim(),
_token: document.getElementsByName("_token")[0].value
};
fetch("{{ route('login2') }}", {
method: 'POST',
headers: {
Accept: 'application/json',
},
body: fields
// body: JSON.stringify(fields)
})
.then(res => {
if (!res.ok) {
throw new Error(`Response Status: ${res.status}`);
}
return res.json();
})
.then(data => {
console.log(data);
})
.catch(error => {
// Handle any errors that occurred during the fetch
console.error('Fetch Catch Error:', error.message);
});