This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes HTML, CSS and JavaScript and the fly likes load array at another time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "load array at another time" Watch "load array at another time" New topic
Author

load array at another time

reubin haz
Ranch Hand

Joined: May 12, 2005
Posts: 287
I create an empty array and pass it to some other function that will display it on the page. (its empty yet)
I want to wait 5 seconds and load some elements to the array, which will be displayed onto the page. But don't how to implment it.
I tried this but failed:



SCJA, SCJP5.0, SCBCD, SCWCD
Purushoth Thambu
Ranch Hand

Joined: May 24, 2003
Posts: 425
I tried this and it worked for me.


and I called preload in body onload event. What error/exception you are getting?
reubin haz
Ranch Hand

Joined: May 12, 2005
Posts: 287
What I would like to do is like the code showing below. The page will show the 1st element of the array first, which is 'undefined', after 5 seconds, I want add something to the array, but the page itself does not change. How should I change to make it work? Thanks.

Purushoth Thambu
Ranch Hand

Joined: May 24, 2003
Posts: 425
setTimeout is not a blocking call. You need to rewrite something similar to this:
 
Consider Paul's rocket mass heater.
 
subject: load array at another time