0

How do i prevent my page to stop scroll to up on an ajax call,

I am using a universal overlay div on ajax start and end like,

$(document).ready(function(e) {
    $("body").on({
        ajaxStart: function() { 
            $(this).addClass("loading");
        },
        ajaxStop: function() { 
            $(this).removeClass("loading");
        }
    });
    //return false // if i use this line, overlay div no more appears
});

Immediately after an ajax call, overlay div appears and page scrolls up.

I am calling it on these evens, 'onclick' 'onblur' 'onchange'

like,

<input type="text" onblur="callAjax(); return false" />
Irfan Ahmed
  • 9,136
  • 8
  • 33
  • 54
  • 3
    `As of jQuery 1.8, the .ajaxStart() method should only be attached to document.` The same of course for `ajaxStop()` – A. Wolff Mar 03 '14 at 13:38
  • possible duplicate of [How to programmatically disable page scrolling with jQuery](http://stackoverflow.com/questions/3656592/how-to-programmatically-disable-page-scrolling-with-jquery) – Ohgodwhy Mar 03 '14 at 13:39

0 Answers0