myvideogamelist.com/resources/assets/extended/button-ajax.js
Jimmy Brancaccio b39ecf1638 Initial Commit
The initial public commit of MVGL website code.
2024-01-14 13:51:43 -06:00

26 lines
649 B
JavaScript
Vendored

$(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();
}
});
});