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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:48:54+00:00 2026-05-12T16:48:54+00:00

Okay, a little preface: I am still a beginner when it comes to AJAX,

  • 0

Okay, a little preface: I am still a beginner when it comes to AJAX, and dynamic web stuff. My problem is similar to what was asked in the following, but I think that discussion is using a framework, and I am not.

Potentially related post

Here is my scenario:

I have several select elements in a form. The initial select’s option elements are populated each time the page loads. The option elements for the subsequent selects get populated depending on what the user selects in the previous select. So it is like a chain. The options in the selects are populated by making AJAX function calls (just my own javascript) that in turn call a php file to get values from a database and build a responseText to fill each subsequent select based on the selection made in the previous select. Hopefully that is clear? All that works fine and dandy.

My problem starts here:

When the user submits the form, a php file is run to process the data, displaying success or any issues, and then I return the user to the form page. I want to reselect all the options they had selected prior to submitting, since some of this is a repetative task and this would save them time. My first step is to recall the required AJAX functions to repopulate the select elements, and then I thought I could run javascript in the form page to select the previously selected options. However, when I try to run javascript on the form page to select the options, it is running before the AJAX calls finish. Therefore, because the options are populated by the AJAX calls, the options do not exist yet in the selects, so I cannot select them. I tried writing some test code to insert a new option to see when the code runs, and sure enough, that new option gets added to the select before my AJAX populated ones go in. In order to track if options were selected, I am passing back the selection option values through the URL, and then processing the $_GET array in my form page.

So my question boils down to:

Is there something I could do that would prevent my javascript that selects the selected options from running until the AJAX populating functions finish?

I would also accept responses like “Your whole approach is bogus! Where did you get your AJAX coding license??!! A Cracker Jack box??” Although, just a few of those responses please, I’m a fragile flower 😉

Thanks in advance,
Carvell Fenton

P.S. Hopefully that’s not too much preamble, but I thought the background was necessary.

  • 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-12T16:48:54+00:00Added an answer on May 12, 2026 at 4:48 pm

    How many levels deep are the chained selects? I’m doing this with only 2 levels (1 ajax driven select) and for the second page load I would add some code to my jquery document ready function that would initiate the ajax call to load the select list but also send it the id of the field I wanted selected so when the ajax call completes it will have loaded my select and also set it’s necessary value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay I have updated my code a little, but I am still not exactly
Okay, it took me a little while to narrow down this problem, but it
Okay this problem will be a little hard to explain but here it goes..
Okay, this scenario is a little complicated, but I will try to explain it
Okay i'm a little bit stuck on how to solve this problem. When a
Okay so my title might be a little confusing, but let me explain my
Still a little gunshy about jQuery. Does this simple popup window script look okay?
okay, my problem is a little bit more difficult than the title would tell...
Okay since I have little experience with this stuff and the Facebook documentation is
Okay I am having a little problem. As soon as you press a button

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.