Click to See Complete Forum and Search --> : DOM Changes Not Posting


win9x23
05-03-2007, 10:52 AM
I am using AJAX (both my own JS code and Prototype) to retrieve some data from a script. The page currently displayed is in a frame and all the code is in the parent. Everything works great. I then tried to add a 'wait' that shows up just before the ajax call and disappears when the ajax call returns. I cannot get anything to work. I have tried opening a new window, changing in image on the page, and inserting a statement using innerHTML. The problem seems to be that whatever I do beofre the AJAX call does not get posted in time. If I add an 'alert' between the 'wait' action and the AJAX call, everything is fine (for example, the window appears). But if I remove the alert I don't see anything. The AJAX call is pretty fast but I added a delay of 5 seconds just to see what was happening and I still do not see my 'wait' action.

I tried IE6 and Firefox, same result.

I know there is probably a simple answer but I guess its not simple enough for me.

win9x23
05-07-2007, 10:54 AM
No responses, so I guess I did not clearly enough state the problem, so here is a code example:

/* 'complete' is an id of a graphic contained in a frame called 'frame1'.
The user has just clicked on a button in this frame which invokes this function in the parent frame */
var vi=frame1.document.getElementById('complete');
tempimgstore.src=vi.src; /* store the current image */
vi.src=waitimgstore.src; /* swap the current image for a different one */
alert('Ready for Ajax...');
var xmlhttp... /* start ajax code */
/* all ajax code goes here. The url called has a 3 second delay so it takes
3 seconds for the response to arrive back */
....
/* end ajax code */
vi.src=tempimgstore.src; /* restore original image */

With the alert code in place everything works fine. If I remove the alert code, I never see the swapped image. It's as if javascript never gets a chance to update the screen based on changes I made to the DOM.

Anyone else run into this? Thanks.