Top.Mail.Ru
? ?
Javascript's Journal
 
[Most Recent Entries] [Calendar View] [Friends View]

Wednesday, February 15th, 2006

Time Event
4:12p
AJAX race conditions

This looks so stupidly simple, but I can't figure it out and it's really holding me up.

Using XMLHttpRequest I can make a function to process the contents of another file, but I can't find a way to make a function to return the contents of another file.

For example, this worksCollapse ) whereas this wontCollapse )

It's obviously a race condition - as XMLHttpRequest runs as a seperate thread the getFile() function is exiting before the inner function has completed and will always return "no data".

Problem is, I can't think of a way to work around it. Can anyone help me out? I'm sure this must be a reasonably common problem.

<< Previous Day 2006/02/15
[Calendar]
Next Day >>
About LiveJournal.com
Image