John, thanks for the reply. Yeah, a timer isn't a good solution for this. I was under the impression that subsequent javascript code would run after the readystate return of 4, or in Prototypes case the onComplete callback fires.
I'm thinking I need to rearrange my code to get it to wait. But that relies on the assumption that js waits for other js to complete before other js down the line is run.
Otherwise maybe I should not be running the Ajax.Request in asynchronous mode. however, I thought that just effected requests... not how js runs.
Here's my code, not to solve the problem, but just to illustrate the concepts.
See the: //THE QEUESTION IS... part
Code:
function setKeySubMeasure(KeyMeasure,KeySubMeasure)
{
document.CONTROL_FORM.KEY_SUB_MEASURE.value = KeySubMeasure;
parent.SELECT_FRAME.document.SELECT_FORM.KEY_SUB_MEASURE.value = KeySubMeasure;
setKeyMeasure(KeyMeasure,KeySubMeasure);
var detailMode = document.CONTROL_FORM.DETAIL_MODE.value;
// THE QUESTION IS.... does the JS continue on to the SWITCH
//while the function 'refreshListArray()' runs...
refreshListArray();
switch(detailMode)
{
case 'ADD':
onclickAdd();
break;
case 'EDIT':
onclickEdit();
break;
case 'VIEW':
displayDetail();
break;
case 'LIST':
displayList();
break;
}
document.CONTROL_FORM.target = 'CONTROL_FRAME';
document.CONTROL_FORM.FUSEACTION.value='control';
document.CONTROL_FORM.submit();
}
function refreshListArray()
{
var keyMeasure = document.CONTROL_FORM.KEY_MEASURE.value;
var keySubMeasure = document.CONTROL_FORM.KEY_SUB_MEASURE.value;
new Ajax.Request('qryListArray.cfm?KEY_MEASURE='+keyMeasure+'&KEY_SUB_MEASURE='+keySubMeasure,
{
method: 'get',
onComplete: setArraySeqID,
onFailure: function(r) {
throw new Error( r.statusText );
}
}
);
}
function setArraySeqID(transport)
{
var transportResponse = transport.responseText;
arraySeqID = transportResponse.evalJSON();
}
Bookmarks