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.