Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

228
Vistas
stop scrolling to top after AJAX request

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

over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

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>
over 4 years ago · Santiago Trujillo Denunciar

0

if you are calling the ajax via anchor click, try this:

<a id="clicker" href="#">Click here to do ajax</a>

$('#clicker').click(function(e) { e.preventDefault(); $.get("/myurl/") })
over 4 years ago · Santiago Trujillo Denunciar

0

Attach the event handler with jQuery (not with the onclick attribute) and remove the href attribute altogether. The problem is that the browser is navigating when the link is clicked. I see this happen alot when onclick is used and there is an error in your event handler before preventing the default.

Another way to fix it for sure is to not use an <a> but rather a <span>.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda