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 6476929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:53:09+00:00 2026-05-25T06:53:09+00:00

My understanding of jQuery is the script will be executed as soon as the

  • 0

My understanding of jQuery is the script will be executed as soon as the document is ready.

I have some dynamically generated HTML that are generated on page load as soon as response is back from server as to what to generate. The HTML are all part of a template. All of those are kicked off with the following line.

   window.App=new AppView;

and right after that line, I have

   alert($("#field").val());

where $(“#field”) is part of the template which was dynamically generated into HTML

And NULL was alerted.

But if I set a setTimeout to carry out the alert, I see a value.
Both lines of code are within the jQuery {}.

Can someone explain why 2nd line is executed before everything in 1st line is executed.

P.S. This is the line that generate the template

     $("body").html($.tmpl("temp", data)); 
  • 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-25T06:53:10+00:00Added an answer on May 25, 2026 at 6:53 am

    I think I just figured out the problem. You said your code involved getting a GET request from the server? Well, that means async code. In other words, here’s what happens:

    You call new AppView
        - Inside AppView, a XHR is created, sending a GET request to server
        - Code finishes inside AppView, and returns to calling function
    You call alert field val (not created yeat)
    Some time later, the GET request is finnished
        - Inside callback-function for GET-request. Your field get's created.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It was my understanding that <script type=text/javascript src=//ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js></script> <script type=text/javascript> $(document).bind('mobileinit', function () {
I have a jQuery script that returns a date as: Wed Nov 09 2011
Jquery: <script type=text/javascript> $(document).ready(function(){ $(form.register).change(function() { $.post(check.php, $(form.register).serialize(), function( data ) { if( data.username
I have a script that will fetch data from server and compose a DIV
I'm very new to JQuery, and I'm having some trouble understanding how to do
I am looking for some help in a jquery script I am in the
I have a situation where I am not understanding jQuery's Toggle. I have two
I'm using jQuery 1.3.2: <script src=../../Scripts/jquery-1.3.2.js type=text/javascript></script> I've got the following html: <div id=container-div>
Simple question that is a flaw in my understanding of JQuery. $('input').focus(function() { $('.popup').click(function()
I'm looking to write a script that will take a bunch of .js files,

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.