I have a code that shows a load symbol when there is an ajax query, everything works well the question is that I have done a dynamic select2 that loads the data with ajax and I find it annoying that when I write in the input the symbol appears in the middle of the screen.
Is there any way to prevent this?
$(function () {
const screen = $('#overlay');
loadingScreen(screen);
});
function loadingScreen(screen) {
$(document).ajaxStart(function () {
screen.fadeIn();
})
.ajaxStop(function () {
screen.fadeOut();
})
}
That's the code I use for when AJAX is activated, show my symbol.