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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:11:16+00:00 2026-06-09T06:11:16+00:00

Here is the scenario: I am getting data from database through web server. Based

  • 0

Here is the scenario: I am getting data from database through web server. Based on that data page sends another request to the same server to perform some action. Simplified structure is the following:

var datacon;
$.post('method',function(data){
   datacon = data;
   // populating some tags;
}) // end of post
//some other staff happening;
$.post('other',{datacon}, function(env){
...// taking data from populated tags
   $("div").load(env);
...
}) // end of post

This happens every time user enters the page. This code doesn’t work in a sense that datacon is empty when the page is opened. But if I will refresh it once or twice, it starts working. Second $.post works perfectly, checked hundreds of times. I changed first $.post with $.get, but it doesn’t help.

Probably it concerns asynchronous / synchronous calls. I don’t understand much why it happens. Please help.

p.s. server is CherryPy.

  • 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-09T06:11:18+00:00Added an answer on June 9, 2026 at 6:11 am

    As these calls are asynchronous, it possible that the second call is running before the first has completed. To ensure that they run in the correct order, place the second ajax call in a done() function at the end of the first. That way, the second will only be run when the first is finished.

    Here is a sample from a project I’m working on:

    
        $("#leftcolumn").activity();
        $.ajax({
                type: "GET",
                url: "/search",
                cache: false,
                data: {searchterm: searchterm}
                }).done( function(reply) {
                    $("#leftcolumn").activity(false);
                    showSearchResults(reply);
                    });
    
    

    The first line shows a progress indicator on the screen. Then the ajax call does a search. At the end in .done, I then disable the progress indicator I was showing and then display the search results. Putting the code I want to execute in .done guarantees that it won’t run until the ajax call is finished.

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

Sidebar

Related Questions

That's a horrible title, sorry. Here's the scenario: WCF Service uses LINQ to get
Here's the scenario: Many users access an application (running on tomcat), the user's data
I'm working on an application which accesses data from an Oracle 11g database. I'm
A common scenario for core data driven apps is getting a unique object out
Here is my scenario. For the example lets say that I need to return
I'm doing a pretty simple thing here, making a POST request to Django from
Here's the scenario: I'm getting .9999999999999999 when I should be getting 1.0 . I
I'm getting an error when saving my core data context, here is the log:
Here is the scenario I'm using this regular expression for getting the text inside
Here the scenario : A method is called each minute by a timer. This

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.