1.Call a first function before calling second function(ajax)
2.In first function , check for a div with specific id’s length
3.In second function(ajax) most top append the div with specific id.
Example:
Event Scroll to Bottom -> Call ajax:
$(window).on("scroll", function() { if($(window).scrollTop() == $(document).height() - $(window).height()){ beforeajaxcalling(); } });
Function to be called before calling ajax:
function beforecallingajax(){ if($("#running").length > 0){ console.log("AJAX IS RUNNING"); }else{ callAjax(); } }
Function ajax with div(with id) appended:
function callAjax(){ $("
“).appendTo(‘#somewhere’); —- REST OF AJAX— }