I am trying the jquery "Please Wait Loading Animation" as here
<script type="text/javascript">
var body = $("body");
$(document).on({
ajaxStart: function () {
console.log("ajax start");
body.addClass("my-loading");
console.log(body.hasClass("my-loading"));
},
ajaxStop: function () {
console.log("ajax stop");
}//$body.removeClass("my-loading"); }}
});
</script>
But I get false when log the class with console.log(body.hasClass("my-loading"));
Why is the class not getting added?
EDIT
The above code is in header section.