How to make non-blocking javascript code?
问题 How can I make a simple, non-block Javascript function call? For example: //begin the program console.log('begin'); nonBlockingIncrement(10000000); console.log('do more stuff'); //define the slow function; this would normally be a server call function nonBlockingIncrement(n){ var i=0; while(i<n){ i++; } console.log('0 incremented to '+i); } outputs "beginPage" "0 incremented to 10000000" "do more stuff" How can I form this simple loop to execute asynchronously and output the results via a