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?