Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

136
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!