用clearInterval()即可搞定。亲测有效
$(document).ready(function(){c = setInterval(checkIsExist,10000);//每10秒执行一次checkIsExist方法
});
function checkIsExist(){$.ajax({type: "POST",url: "/SecondServlet",data: "date="+new Date(),success: function(rtmsg){if(rtmsg == 'exist'){window.clearInterval(c);}}
}
);}
参考自https://wenda.so.com/q/1376902471067274