var timer = window.setInterval("getNewOrders()", 15000);
function getNewOrders()
{
var cTime = $("#cTime").text();
$.ajax({
type:'get',
url:'ajaxAdmin.php?request=getNewOrders&+cTime='+cTime,
dataType:'json',
success:function(data){
$("#cTime").text(data.time);
if(data.status == 1){
window.clearInterval(timer);
var errorHtml=$('#errorMp3').text();
var html_='<audio src="../msg.wav" autoplay="autoplay" style="height:0; width:0;" controls="controls" />';
$("#addDiv").append("<div id='target4' style='overflow-x: hidden; overflow-y: auto; width:660px;'></div>");
$("#target4").html(data.info);
$.ligerDialog.open({
target: $("#target4"),
width: 700,
height: 300,
title:"",
buttons: [
{
text: '取消', onclick: function (item, dialog) {
var timer = window.setInterval("getNewOrders()",15000);
dialog.close();
}
}
]
});
}
},
});
}
去掉var,要不timer是匿名函數中私有變量,不是 var timer = window.setInterval("getNewOrders()", 15000);
function getNewOrders()
這個timer
text: '取消', onclick: function (item, dialog) {
timer = window.setInterval("getNewOrders()",15000);