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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:41:52+00:00 2026-06-12T14:41:52+00:00

I have succeeded in getting all of the necessary components working to trigger updates

  • 0

I have succeeded in getting all of the necessary components working to trigger updates in cascading dropdowns with the following code when I have alert messages firing.

However, when I comment out the alerts it appears that things move too quickly. Is there a way to ensure that my source dropdown has completed its update prior to firing the change on my destination dropdown?

$(document).ready(function() {
     //Default bu (company) listing
     $.post("select_bu.php", {
         id: 1
     }, function(data) {
         $("select#id_buid").html(data);
     });
     //Default division listing
     $.post("select_division.php", {
         id: 1
     }, function(data) {
         $("select#id_divid").html(data);
     });
     //Default department listing
     $.post("select_dept.php", {
         divid: 11
     }, function(data) {
         $("select#id_deptid").html(data);
     });
     //Default title listing
     $.post("select_title.php", {
         deptid: 12
     }, function(data) {
         $("select#id_titleid").html(data);
     });
     //Default location listing
     $.post("select_loc.php", {
         id: 1
     }, function(data) {
         $("select#id_locid").html(data);
     });
     //Change to Business Unit triggers updated division listing and location
     $("select#id_buid").change(function() { * //alert("Change of BU triggering change in Division and Location.");*
         var id = $("select#id_buid option:selected").attr('value');
         $.post("select_division.php", {
             id: id
         }, function(data) {
             $("select#id_divid").html(data);
         });
         $.post("select_loc.php", {
             id: id
         }, function(data) {
             $("select#id_locid").html(data);
         });
         $("#id_divid").trigger("change");
     });
     //Change to Division triggers updated department listing
     $("select#id_divid").change(function() {
         //alert("Change of Division triggering change in Department.");
         var id = $("select#id_divid option:selected").attr('value');
         $.post("select_dept.php", {
             divid: id
         }, function(data) {
             $("select#id_deptid").html(data);
         });
         $("#id_deptid").trigger("change");
     });
     //Change to Department triggers updated title listing
     $("select#id_deptid").change(function() {
         //alert("Change of Department triggering change in Title.");
         var id = $("select#id_deptid option:selected").attr('value');
         $.post("select_title.php", {
             deptid: id
         }, function(data) {
             $("select#id_titleid").html(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-06-12T14:41:53+00:00Added an answer on June 12, 2026 at 2:41 pm

    You should move triggering to the success function of $.post. Ajax call is done asynchronously, which means that after creating the request script moves to the next command and ajax request is handled in the background. If you want them to appear one after another you have to call the next in the response handler of the previous. So it can look like that:

    $("select#id_buid").change(function() { * //alert("Change of BU triggering change in Division and Location.");*
         var id = $("select#id_buid option:selected").attr('value');
         $.post("select_division.php", {
             id: id
         }, function(data) {
             $("select#id_divid").html(data);
             $.post("select_loc.php", {
                 id: id
             }, function(data) {
                 $("select#id_locid").html(data);
                 $("#id_divid").trigger("change");
             });
         });
     });
    
     $("select#id_divid").change(function() {
         //alert("Change of Division triggering change in Department.");
         var id = $("select#id_divid option:selected").attr('value');
         $.post("select_dept.php", {
             divid: id
         }, function(data) {
             $("select#id_deptid").html(data);
             $("#id_deptid").trigger("change");
         });
    
     });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Source code at: http://jsfiddle.net/lski/4aTm5/ I have succeeded in getting the above code in Firefox,
I have followed the tutorial for getting a Thunderbird extention going and succeeded in
I need to know if all the client-side validator checks have succeeded, or if
I am trying to do the following and I have not yet succeeded. I
im trying to import html table data to an excel file and have succeeded
I am using Openlayers to my application. i have succeeded in showing marker when
I am trying to create a windows explorer. I have succeeded in populating the
I have just succeeded in creating oAuth authentication for my twitter application using PHP.
I have an XML structure that looks like: <Succeeded p1:type=Edm.Boolean xmlns:p1=http://schemas.microsoft.com/ado/2007/08/dataservices/metadata xmlns=http://schemas.microsoft.com/ado/2007/08/dataservices>false</Succeeded> Since I
i been trying to code an IRC bot, while i have succeed. I am

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.