JQuery SetTimeout before running code
<p>I'm trying to run a function in JQuery that basically shuts down or starts up a server. The code I have so far is this -</p>

<pre><code>$(".stopServer").click(function(){
    $.post("controller.php",{stop: 'true', server: this.name});
    $('#test'+this.name).load('controller.php?status=true&amp;server='+this.name);
});
</code></pre>

<p>The problem is obviously it stops the server fine but it updates the status div ('#test'+this.name) straight away. This is no good because the server takes a period of time to shut down. I've been trying to get SetTimeout to work but can't figure it out... Any help would be appreciated.</p>

<p>Thanks guys, you're the best :)</p>

<p>UPDATE:</p>

<p>Full functions are here:</p>

<pre><code>$(document).ready(function() {

$(".startServer").click(function(){
    $.post("controller.php",{server: this.name});
    setTimeout("showStatus('"+this.name+"')", 3000);
});

$(".stopServer").click(function(){
    $.post("controller.php",{stop: 'true', server: this.name});
    setTimeout("showStatus('"+this.name+"')", 3000);
});

function showStatus(name) {
    alert(name);
    $('#test'+name).load('controller.php?status=true&amp;server='+name);
}
});
</code></pre>

<p>UPDATE</p>

<p>Given up on the idea of it, instead the status is polled for every second instead.</p>

<pre><code>var refreshId = setInterval(function()
{
    $('.status').each(function() {
    var $name = $(this).attr('name');
    $(this).load("controller.php?status=true&amp;server=" + $name);

});
}, 1000);
</code></pre>
