I have a submit event:
$('#id').on('submit', function(e) {
e.preventDefault();
clicksCounter++;
$.ajax({
type: 'POST',
data: {
id: id,
clickCounter: clicksCounter > 1
},
url: 'url',
success: function(response) {
if (response) {
$('#modal').modal('hide');
}
}
});
});
But somehow it's redirecting me to another page instead of going to the function. I thought that e.preventDefault()
will help, but it didn't. Also tried location.reload()
, but it didn't helped either.
Could someone explain me why? Thank you for your time