2017  Kodetalk | Feedback | Privacy Policy | Terms | About
userimage

Disable page scrolling on AJAX call or event using JQuery

I made some AJAX call to avoid page reload or refresh which is working fine.

But when click on the event to fire an AJAX call immediately my page going to be scroll up which I don"t want.

Need some suggestion on this to stop page scrolling on AJAX call.

userimage

The below code snippet will fix your problem.

var current = $(window).scrollTop();

$(window).scroll(function() {

   $(window).scrollTop(current);

});

From above we can stop to scroll the window at the time of AJAX call and after success the below code will be for reset the window as it is.

$(window).off('scroll');
Answer is