Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

load array at another time

 
reubin haz
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:

 
Purushoth Thambu
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 287
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
setTimeout is not a blocking call. You need to rewrite something similar to this:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic