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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:53:36+00:00 2026-05-28T07:53:36+00:00

I have an issue when trying to get Javascript to execute functions in my

  • 0

I have an issue when trying to get Javascript to execute functions in my desired order. I’m trying to get a jQuery modal form to load information based on a certain selection. I have two SELECT boxes that need to be loaded, but the contents of the second SELECT box depend entirely on the selected value of the first SELECT box.

I made the following functions to request the information I need:

function get_Subjects(varID, callback){
    $.post("../vars/get_SID.php", { vid : varID },  
        function(result){
            getInfo('tbsubjectdiv', '../vars/findSubjectlist.php?sid='+result);
        });
    callback();
}

function get_Selectedfields(varID, callback){
    $.post("../vars/requestTblock.php", { vid : varID },  
        function(result){
            populateForm('tbWiz', result);
            document.form_tbWiz.varname.disabled = true;
            $('.trSearch').hide();
            $('.trValueset').hide();
        });
    callback();
}

function get_TextblockType(varID, callback){
    $.post("../vars/requestVtype.php", { vid : varID },  
        function(result){
            if(result == 0){ //Opzoeken
                $('.trSearch').show();
            }else if(result == 1){ //Datum vergelijken
                $('.trSearch').show();
                $('.trValueset').show();
            }else if(result == 2){ //Percentage
                //
            }
        });
    callback();
}
  1. The first function checks the MySQL database for the selected value
    of the FIRST SELECT field, and loads the results into the second
    SELECT field.

  2. The second function requests the rest of the rest of the form data, and populates the form using populateForm(). It also hides
    certain parts of my form in preparation for function three.

  3. The third function basically requests which parts of the form have to be displayed, because that’s not always the same.

The whole idea behind this is that I want to use populateForm() to populate all of the form fields. In order for populateForm() to properly set the selected SELECT option, the particular SELECT field must first contain the OPTION it needs to select. Makes sense. I try to make sure of this with my first function, which will load all of the OPTIONs. THEN I try to use the get_Selectedfields() to populate all the proper values. This is not what happens though. No matter what I try to do, getInfo() in the first function is ALWAYS being called LAST. This makes it impossible for populateForm() to select the proper option, which is driving me mad.

I’m trying to “force” the execution-order by doing this:

function getTextblock(var_ID){
get_Subjects(var_ID, function() {
    get_Selectedfields(var_ID, function() {
        get_Textblocktype(var_ID, function() {
            // Done
        });
    });
}); 

}

When I realised it still did not work the way I wanted, I decided to use Chrome’s Developer Tools to check the order in which everything is executed. It all works as expected, but at the very end it jumps straight back to getInfo(), which is part of the FIRST function I called. I’m absolutely clueless as to why getInfo() gets executed last. If this just gets executed at the very beginning, where I want it to execute, it would all work fine.

  • 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-28T07:53:37+00:00Added an answer on May 28, 2026 at 7:53 am

    You have to call the callback in the callback function of the post request:

    function get_Subjects(varID, callback){
        $.post("../vars/get_SID.php", { vid : varID },  
            function(result){
                getInfo('tbsubjectdiv', '../vars/findSubjectlist.php?sid='+result);      
                callback();
            });
    
    }
    
    function get_Selectedfields(varID, callback){
        $.post("../vars/requestTblock.php", { vid : varID },  
            function(result){
                populateForm('tbWiz', result);
                document.form_tbWiz.varname.disabled = true;
                $('.trSearch').hide();
                $('.trValueset').hide();
                callback();
            });
    
    }
    
    function get_TextblockType(varID, callback){
        $.post("../vars/requestVtype.php", { vid : varID },  
            function(result){
                if(result == 0){ //Opzoeken
                    $('.trSearch').show();
                }else if(result == 1){ //Datum vergelijken
                    $('.trSearch').show();
                    $('.trValueset').show();
                }else if(result == 2){ //Percentage
                    //
                }
                callback();
            });
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently having an issue where I have a javascript object that is trying
I'm trying to make a generic javascript dialog-class based on JQuery to create div-popups
I have a jQuery issue I can't get past: (function ($) { var links
I have ran into an interesting issue while trying to create a more usable
can anyone help? I have an issue with linq2sql and trying to Attach (update)
The issue I am trying to solve is that I have a folder with
I'm trying to adress the following issue: I have a server side .net application
I’m trying to issue web requests asynchronously. I have my code working fine except
Ok so I've spent a couple hours trying to resolve this issue and have
We have a MS Enterprise 2003 CA. I am trying to issue a certificate

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.