Seeking advice on how to restrict access to an ajaxStart function in a JavaScript file to only certain pages.
The code snippet below shows the current implementation:
$(document).ready(function()
{
$(document).ajaxStart(function()
{
$("#overlay").css
({
"display" : "block",
"background-color" : "rgba(255, 255, 255, 0.4)",
"width" : $(document).width(),
"height" : $(document).height(),
"position" : "absolute",
"z-index" : 99999
})
});
$(document).ajaxComplete(function()
{
$("#overlay").css("display", "none");
});
});
This HTML snippet below displays a loading gif inside a div upon button click events that are triggered from various HTML pages:
<div id="overlay" style="display:none">
<img src='loading.gif'/>
</div>