Possible Duplicate:
How do I stop a web page from scrolling to the top when a link is clicked that triggers javascript?
my browser scrolls to top after ajax request then i use
$('html, body').animate({ scrollTop: $('#loadMore').offset().top }, 2000);
to scroll back to my div. is there a way i stop it from scrolling to top from the beginning
ajax({ type: 'POST', url: 'someurl', success: function(result){} }); request. abort();
We can't prevent scrolling by using event. preventDefault() in onscroll listener, because it triggers after the scroll has already happened. But we can prevent scrolling by event. preventDefault() on an event that causes the scroll, for instance keydown event for pageUp and pageDown .
ajax({ type: 'POST', url: 'increment. php', data: $(this). serialize(), dataType: 'json', success: function (data) { $('#hidden'). val(data);// first set the value }, complete: function (data) { // Schedule the next setTimeout(doAjax, interval); } }); } setTimeout(doAjax, interval);
you should add return false
to the end of your ajax call function. Or to the end of your inline call:
<a href="#" onclick="someAjaxCall(); return false">Link</a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With