Skip to content

Instantly share code, notes, and snippets.

@vendethiel
Forked from dtolj/gist:3005981
Created June 28, 2012 13:21
Show Gist options
  • Save vendethiel/3011345 to your computer and use it in GitHub Desktop.
Save vendethiel/3011345 to your computer and use it in GitHub Desktop.
auto refresh
#Controller
def action
@tm=Random.rand(11)
render :layout => false
end
#View
#action.haml
=@tm
#index.haml
#mydiv
#/app/assets/javascripts/refresh.js
$(document).ready(
function refreshMyDiv(){
$('#mydiv').load('action', function () {
setTimeout(refreshMyDiv, 16100);
});
}
refreshMyDiv();
});
Output:
action,GET,200,text/html,application.js:18,1.29KB,21ms
action,GET,200,text/html,application.js:18,1.29KB,45ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment