2017  Kodetalk | Feedback | Privacy Policy | Terms | About

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.


The below code snippet will fix your problem.

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

$(window).scroll(function() {



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.

Answer is