I have a situation in which I am trying to execute a a method which will eventually populate a view on UI. wanted to see if someone can guide me correctly.
On startup on jquery I call some functions as:
function XYX(){
//Do Some stuff basically find some div's on UI and set them
//Make a ajax call
$.ajax(
{
}).
done(function(data){
//Use the data to set some values on UI
})
}
function PQR(){
//Do Some stuff basically find some div's on UI and set them
//Make a ajax call
$.ajax(
{
}).
done(function(data){
//Use the data to set some values on UI
})
}
Now what happens is that the returned results from the two ajax calls are setting fields on UI which I eventually want to use to set another view which again makes a ajax call and then uses its own result and result from XYZ and PQR to set something.
function FINAL(){
//Do Some stuff basically find some div's on UI and set them
//Make a ajax call
$.ajax(
{
}).
done(function(data){
//Use the data and fields set by XYZ() and PQR() to set some values on UI
})
//Do some other stuff
}
Being AJAX calls I cannot trust the results to be available when the FINAL function is called and I cannot combine the three to generate the view.
What would be the best way to handle this scenario.