jquery - How to autorefresh asp.net MVC webpage if condition is met in background -
i working on having following functionality mvc website. want have, example 5 selected users voting on question. when user has voted, remain in 'waiting' state until has answered. once 5 users have answered, page autorefresh , can populate next question.
my basic thinking need following pseudocode execute every (say 10 seconds) check status, possibly in jquery... controller can populate next question.
while(condition not met) { } //wait refresh()
is there simple way fulfil functionality?
thanks.
your thinking correct. uusing jquery.get on timer method call jquery. call url (route/controller) see if voting has completed , examine data in resulting function set callback in jquery.get function. if condition true, jquery can call method using jquery.load() results , update div such as:
$('#question').load('/voting/nextquestion/10');
see following error handling when call jquery methods jquery error handling
Comments
Post a Comment