Forum Moderators: open
I am simply trying to initate 2 ajax scripts on the press of a button. The script simply passes the div id to replace the results and the name of the file to execute.
However, I think as the scripts seem to be running so close together the div ids are getting mixed up and the second results are being put in the first div...
Is there a simple way I can prevent the second ajax script from being run until the first one is completed?
Thanks,
Dave
// request 1
new Ajax.Request('/example_script.php', {
method: 'get',
onSuccess: function(transport) {
// request 2, inside of the onSuccess callback
new Ajax.Request('/example_script_2.php', {
method: 'get',
onSuccess: function(transport) { alert('both done!'); }
});
}
});