停止 setInterval 并执行其余代码
Stopping setInterval and executing the rest of the code
所以如果满足 $('#purple-title').html() != "PLEASE SCAN YOUR CARD" 的条件,我想退出间隔并执行里面的操作那个 if() 函数。
我的问题已经解决,下面的代码运行正常!
$(document).ready(function() {
$.ajaxSetup({
cache: false
});
var refreshID = setInterval(function() {
$('#purple-title').load('dbcheck.php');
if ($('#purple-title').html() != "PLEASE SCAN YOUR CARD") {
clearInterval(refreshID);
$("#waiting-for-signal").animate({
opacity: '0'
}, 300);
$("#purple-title").animate({
opacity: '0'
}, 300);
setTimeout(function() {
$("#waiting-for-signal").css("visibility", "hidden");
$("#purple-title").html("Welcome!");
$("#screen").prepend('<img id="checked" src="assets/check.gif"/>');
$("#screen").prepend('<p id="purple-title" class="purple-title" style="margin:20px 0px 0px 0px;">WELCOME<br /><br /><strong>ALEN ŠIMUNIC</strong><br /><br />UID: 31.42.43.25</p>');
$("#checked").css("opacity", "1");
}, 300);
$("#purple-title").animate({
opacity: '1'
}, 300);
setTimeout(function() {
$("#purple-title").animate({
opacity: '0'
}, 300);
$("#checked").animate({
opacity: '0'
}, 300);
}, 2200);
setTimeout(function() {
location.reload();
}, 2500);
}
}, 500);
});
clearInterval(refreshID);
就是这样...
所以如果满足 $('#purple-title').html() != "PLEASE SCAN YOUR CARD" 的条件,我想退出间隔并执行里面的操作那个 if() 函数。
我的问题已经解决,下面的代码运行正常!
$(document).ready(function() {
$.ajaxSetup({
cache: false
});
var refreshID = setInterval(function() {
$('#purple-title').load('dbcheck.php');
if ($('#purple-title').html() != "PLEASE SCAN YOUR CARD") {
clearInterval(refreshID);
$("#waiting-for-signal").animate({
opacity: '0'
}, 300);
$("#purple-title").animate({
opacity: '0'
}, 300);
setTimeout(function() {
$("#waiting-for-signal").css("visibility", "hidden");
$("#purple-title").html("Welcome!");
$("#screen").prepend('<img id="checked" src="assets/check.gif"/>');
$("#screen").prepend('<p id="purple-title" class="purple-title" style="margin:20px 0px 0px 0px;">WELCOME<br /><br /><strong>ALEN ŠIMUNIC</strong><br /><br />UID: 31.42.43.25</p>');
$("#checked").css("opacity", "1");
}, 300);
$("#purple-title").animate({
opacity: '1'
}, 300);
setTimeout(function() {
$("#purple-title").animate({
opacity: '0'
}, 300);
$("#checked").animate({
opacity: '0'
}, 300);
}, 2200);
setTimeout(function() {
location.reload();
}, 2500);
}
}, 500);
});
clearInterval(refreshID);
就是这样...