Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 932897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:44:36+00:00 2026-05-15T20:44:36+00:00

I have an ASP .NET page where I use jQuery. I used this function

  • 0

I have an ASP .NET page where I use jQuery. I used this function to search an element in the DOM

$(document).ready(function() {

        currentID = $('#ctl00_ContentAreaPlaceHolder_hfCurrentID').val();
        if (currentID != "") {
            window.setTimeout(function() {
                $("div[class^='element'][ID='" +currentID + "']").trigger("click");
                $(window).scrollTop(500);
            }, 6000);
        } });

The problem is that when this code is executed al the DOM is not loaded, because I use an ajax call to create the grid that contains the ‘element_r1c1’ (r means row, and c means column) elements. Thats why I use the window.setTimeout to wait until the DOM is loaded, but this only works if the DOM is loaded in less than 6 seconds. So, I need a way to tell this function to execute after the ajax function has ended. For additional info, this code is in the page (.aspx) and the ajax function is in a control (.ascx)

Update:

I have two pages, the BasePage, the GridPage. The control is in the GridPage, and is called by the first page with

$('#tabs').tabs({

        select: function(event, ui) {
            // default shows All action elements
            $.ajax({
                url: 'GridPage.aspx?viewingDate=' + $(ui.tab).attr('Date'),
                cache: false,
                dataType: "html",
                success: function(data) {
                    //debugger;
                    $('#tabContent').empty().html(data);
                }
            });
            $('#nPaneArea').html('').removeClass().addClass('Pane');
        }
    });
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T20:44:37+00:00Added an answer on May 15, 2026 at 8:44 pm

    Instead of waiting an arbitrary period of time and then executing unconditionally, check to see if you actually got anything with your jQuery selector every couple hundred milliseconds before acting.

    function triggerClickOnReady(id) {
        return (function() {
            var $element = $("#" + id);
            if ($element.size() > 0) {
                $element.trigger("click");
                $(window).scrollTop(500);
            } else {
                window.setTimeout( triggerClickOnReady(id), 200);
            }
        });
    }
    

    You’ll need to return a function so that you can pass in currentId and hold its value with a closure.

    Then, in the success callback in your AJAX request…

    success: function(data) {
        $('#tabContent').empty().html(data);
        triggerClickOnReady(currentId);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.