Вот мой код, он выполняет проверку, а также вставляет новый пароль, но проблема даже в том, что пароль успешно изменен, но это выдало ошибку «ошибка запроса: не определено» Может кто-нибудь выяснить, в чем проблема в моем коде ?
$('.changep').click(function () {
var id = $(this).data('change');
var name = $(this).data('name');
Swal.fire({
title: 'Enter New Password of ' + name,
input: 'text',
inputPlaceholder: 'new password',
inputAttributes: {
autocapitalize: 'off'
},
showCancelButton: true,
confirmButtonText: 'Change Password',
showLoaderOnConfirm: true,
preConfirm: function (password) {
return $.ajax({
url: "user/" + id + "/change-password",
type: 'get',
data: {
"_token": "{{csrf_token()}}",
"id": id,
"password": password
},
dataType: "json",
success: function (response) {
},
}).then(response => {
if (!response.ok) {
throw response.errors
}
return response.json()
}).catch(error => {
Swal.showValidationMessage(
`Request failed: ${error}`
)
});
},
allowOutsideClick: () => !Swal.isLoading()
}).then((response) => {
if (response.password) {
Swal.fire({
title: `Password Changed Successfully`,
text: `new password is ${response.password}`
})
}
})
})