I try to do something basic but i block.
I want to add a class to a div for loading when i click on "GO" and remove the class when i get the answer.
My code is :
$.ajax({
url: "/send_email",
type: "POST",
data: $('form').serialize(),
beforeSend: function() {
$('div.loading').classList.add('d-block');
},
})
.done(function(response) {
$('div.loading').classList.remove('d-block')
$('div.message').html(response);
});
return false;
};
The HTML is :
<div class="loading">Loading</div>
What im doig wrong ?
Actualy the page reload and in the console i get: Cannot read properties of undefined (reading 'add')
i try to find my div seperatly and i get it !
I want to show and hide the loader