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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:51:35+00:00 2026-05-14T21:51:35+00:00

Using a form in a dialog box I am using Dojo in jsp to

  • 0

Using a form in a dialog box I am using Dojo in jsp to save the form in my database. After that request is completed using dojo.xhrPost() I am sending in another request to update a dropdown box that should include the added form object that was just saved, but for some reason the request to update the dropdown is executed before saving the form in the database even though the form save is called first. Using Firebug I can see that the getLocations() request is completed before the sendForm() request. This is the code:

<button type="button" id="submitAddTeamButton" dojoType="dijit.form.Button">Add Team
                    <script type="dojo/method" event="onClick" args="evt">

                        sendForm("ajaxResult1", "addTeamForm");
                        dijit.byId("addTeamDialog").hide();
                        getLocations("locationsTeam");
                    </script>

function sendForm(target, form){
    var targetNode =  dojo.byId(target);

    var xhrArgs = {
        form: form,
        url: "ajax",
        handleAs: "text",
        load: function(data) {

            targetNode.innerHTML = data;
        },
        error: function(error) {
            targetNode.innerHTML = "An unexpected error occurred: " + error;
        }

    }

    //Call the asynchronous xhrGet
    var deferred = dojo.xhrPost(xhrArgs);
}

function getLocations(id) {
    var targetNode =  dojo.byId(id);

    var xhrArgs = {
        url: "ajax",
        handleAs: "text",
        content: {
            location: "yes"
        },
        load: function(data) {

            targetNode.innerHTML = data;
        },
        error: function(error) {
            targetNode.innerHTML = "An unexpected error occurred: " + error;
        }
    }

    //Call the asynchronous xhrGet
    var deferred = dojo.xhrGet(xhrArgs);
}

Why is this happening? Is there way to make the first request complete first before the second executes?

To reduce the possibilities of why this is happening I tried setting the cache property in xhrGet to false but the result is still the same.

Please help!

  • 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-14T21:51:36+00:00Added an answer on May 14, 2026 at 9:51 pm

    As Alex said, asynchronous requests are just that – their order is not guaranteed. If you want to guarantee their order, you can make them synchronous if you like. There is an option sync: true I think that you can send with the request args. This causes the browser to freeze up until the request gets back, so it’s not recommended unless you have no other option, and the request is very quick.

    You can also submit whatever data you need along with the data of the current request. For example, suppose dropdown A’s value determines the list choices available in dropdown B. Rather than submitting a change when dropdown A is changed, then refreshing dropdown B’s choices, what you can do is submit A’s value at the time when dropdown B is opened, and process it in the server logic that determine’s B’s choices. (This assumes you have a drop-down widget with choices generated by the server, rather than a standard tag.)

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

Sidebar

Related Questions

No related questions found

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.