我想在基本上关闭或启动服务器的JQuery中运行一个函数。我到目前为止的代码是这样的 -运行代码之前的JQuery SetTimeout
$(".stopServer").click(function(){
$.post("controller.php",{stop: 'true', server: this.name});
$('#test'+this.name).load('controller.php?status=true&server='+this.name);
});
显然,问题就停止服务器不错,但它更新状态DIV(“#测试” + this.name)直线距离。这是不好的,因为服务器需要一段时间才能关闭。我一直试图让SetTimeout工作,但无法弄清楚...任何帮助将不胜感激。
感谢球员,你是最好的:)
UPDATE:
完整的功能如下:
$(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&server='+name);
}
});
UPDATE
放弃它的想法,而不是相反,状态每秒调查一次。
var refreshId = setInterval(function()
{
$('.status').each(function() {
var $name = $(this).attr('name');
$(this).load("controller.php?status=true&server=" + $name);
});
}, 1000);
我放弃了,我只是每秒调查一次状态。 – Steve
@Steve - cool;如果你决定改变主意,那么这里是演示!祝你好运! – f0x
不管我想要什么,所以我会给你选择的答案:)感谢哥们:) – Steve