file-management-system/resources/mix/common/button-ajax.js
Daeng Deni Mardaeni c73ea1b54c update metronic 8.2
2023-09-26 16:51:59 +07:00

27 lines
649 B
JavaScript

$(document).on('click', '.button-ajax', function (e) {
e.preventDefault();
var action = $(this).data('action');
var method = $(this).data('method');
var csrf = $(this).data('csrf');
var reload = $(this).data('reload');
axios.request({
url: action,
method: method,
data: {
_token: csrf
},
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
})
.then(function () {
if (reload) {
window.location.reload();
}
});
});