在我的应用程序中,每隔10秒钟,它就会调用此ajax来重新加载收到的邮件数。
但是,随着时间的推移,我的电脑似乎变得越来越热,即使我什么都不做,只是留在应用程序的同一页面而已。如何在每次运行时延长间隔时间?
我想在每次运行时再增加10分钟。
然后它重置为0,当整个页面再次加载。
可能吗?
refresh_mail_count.js
jQuery(document).ready(function() {
refreshMail();
});
function refreshMail() {
$.ajax({
url: "/messages/refresh_mail",
type: "GET",
dataType: "script",
});
}
refresh_mail.js.erb
$('#message_count').html("<%= j(render(:partial => 'layouts/message_received_count', :object => @message_count)) %>");
setTimeout(refreshMail,10000);
由于这是一个完美的答案是我想要的 – cat