Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

load array at another time  RSS feed

 
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:
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!