[ACCEPTED]-stop scrolling to top after AJAX request-scroll
Accepted answer
you should add return false
to the end of your ajax 2 call function. Or to the end of your inline 1 call:
<a href="#" onclick="someAjaxCall(); return false">Link</a>
if you are calling the ajax via anchor click, try 1 this:
<a id="clicker" href="#">Click here to do ajax</a>
$('#clicker').click(function(e) { e.preventDefault(); $.get("/myurl/") })
Attach the event handler with jQuery (not 8 with the onclick attribute) and remove the 7 href attribute altogether. The problem is 6 that the browser is navigating when the 5 link is clicked. I see this happen alot 4 when onclick is used and there is an error 3 in your event handler before preventing 2 the default.
Another way to fix it for sure 1 is to not use an <a> but rather a <span>.
/* AJAX stuff here */
$('html, body').stop();
0
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.