I am using javascript remoting. I have a situation where I need remote actions to execute in order.
The problem I am running into is the second remote action executes prior to the first one finishing. Since remote actions are asynchronous, is it possible to execute them in order? What is the best way to do so?
Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.ChoptankRates.method1}',
document.getElementById('var1').value,
function(result, event) {
document.getElementById('var1').value = result[0].somevalue;
//SECOND REMOTE ACTION SHOULD EXECUTE NOW.
}
);
Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.ChoptankRates.method2}',
document.getElementById('var1').value,
function(result, event) {
//do something here
}
);