Use a flag, check for it and set it to false on complete
let shouldAjax = true;
// later
if (shouldAjax) {
$.ajax({
type: "POST",
url: "/php/auth/login.php",
data: $("#login-form").serialize(),
success: function(msg) { //stuffs
},
complete: function() {
$(this).data('requestRunning', false);
shouldAjax = false;
}
});
}
solved when click on the element, ajax request loaded data in first time, after first time prevent ajax request