Posted in Javascript onMarch 16, 2012
(function() { var t = window.setInterval(function() { $('#ajaxGame').load('RefreshCurrentPlayerServlet #ajaxGame', function() { youWin(); youlose(); }); }, 10000); function youWin() { if ($('#status:contains("YOU ARE THE WINNER!")').length) { alert("YOU ARE THE WINNER!"); clearInterval(t); } } function youlose() { if ($('#status:contains("You lost!")').length) { alert("You lost!"); clearInterval(t); } } });
JavaScript异步调用定时方法并停止该方法实现代码
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@