ruby on rails - How can I extend interval time every time it runs? -



ruby on rails - How can I extend interval time every time it runs? -

in application, every 10 seconds, calls ajax reload number of received mails. however, seems pc getting heated time goes by, when i'm doing nil staying @ same page in application.

i'd add together extensional 10 more seconds every time runs. resets 0, when whole page loaded again. possible?

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);

you can define global javascript variable on view. window.timercounter = 0 increment variable on refresh_mail.js.erb

window.timercounter += 1 settimeout(refreshmail, 10000 + (window.timercounter * 10000));

ruby-on-rails ajax ruby-on-rails-3 jquery

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -