Problem synchronizing successive Ajax calls

View: New views
1 Messages — Rating Filter:   Alert me  

Problem synchronizing successive Ajax calls

by JavaRunner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have a JSP that renders up to 6 SELECT elements. Each SELECT is dependent on the preceding SELECT.
At startup the app grabs a default value for each SELECT and uses this value to pre-select an option.
This option value then becomes a retrieval argument value in a SQL stmt that retrieves data for the following SELECT.
My problem is this:
The functions containing the Ajax calls are firing before the code to pre-select the preceding SELECT has completed.
Hence an incorrect argument is passed to the SQL.
I have tried using setTimeout but IE gets in the way and reports 'Slow running script bla bla'. Setting various Advanced IE options
suggested by several Google searches hasn't helped. One suggestion involved setting a Registry entry. That did not work either, and
since this is commercial software it's difficult to ensure all users make the necessary Registry changes even if it had worked.
I've also tried setInterval. This will fire a function that can test for a specific variable value that I can set when the
scripts have completed, and then I clearInterval when I find the value has been set.
This doesn't work too well either.
Using IE is mandatory in this case. :evil: :evil:
Any one have any suggestions that might resolve this issue?