Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

145
Visualizações
jquery redirect to another page anchor on ajax success

In jQuery, I am trying to redirect to an anchor point of a new page on ajax success.

This is how I tried it.

$(document).on('click', '.user-log', function(e) {
  e.preventDefault();
  var logID = $(this).data('log-id'); 
  $.ajax({
    type: "POST",
    url: '/update_log_status.inc.php',
    data: {'logID': logID}, 
    success: function(json) {
      json = jQuery.parseJSON(json);          
      if (json.success) {
        $(window).attr('location','view-log#row_11');

        window.jQuery("html, body").animate({
          scrollTop: $('#row_11').offset().top - 100
        }, 500);   
        
      }
    } 
  })
}); 

In my code, redirect is working, but I am getting a console error.

That error message as follows:

Uncaught TypeError: $(...).offset() is undefined

This error is saying about this line;

scrollTop: $('#row_11').offset().top - 100

This redirect page have a jquery datatable and this #row_11 anchor is a row of that table.

Can you tell me what would be the reason for this issue?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda