Not only will that lock up the current browser, in many browsers it will lock up *every* browser window or tab. Plus, if someone is running on battery power it will drain the battery needlessly.
As Richard said, setTimeout is the right solution: doSomething(); setTimeout( function() { doSomethingLater(); }, 5000 ); -Mike > From: Joe > > // Similar to PHP's sleep function. > function pause(numOfSeconds) { > > numOfSeconds *= 1000; > var startTime = new Date().getTime(); > while (new Date().getTime() < startTime + numOfSeconds); > return false; > } > > // Let's pause for 5 seconds... > pause(5); > console.log('Awake Now'); > > A simple way of doing it, but it will lock the browser... > > Cheers. > > Joe > > http://www.subprint.com > > On Dec 30, 10:23 am, bwdev <pel...@gmail.com> wrote: > > I have the following code and want to basically write > something out, > > let it sit for a while, and then write something else > out...how do I > > do the pause/wait? > > > > Thanks! > > > > myURL="getSearchResults.php"; > > $.getJSON(myURL, function(data) { > > for (var i=0; i < data.length; i++) > > > > > > $("#searchResults").html(data[i]); > > //I want to pause here.... > > > > }); >