开发者

JSP Timer Reset problem

I created an online quiz, users have to finish the test within the time. I found a timer javascript code. It开发者_如何学Python works, but when i submit one question and go to next question the timer reset. Any idea how i can solve this problem?


You need to manage the timer on server side session. So, when the user starts a test

  1. create a session on the server
  2. attach timer to the session
  3. for each question submit check the timer


The problem is that the javascript code is executed when the html code is received by the browser, so when it "leaves" the page and load another one (for example when you submit a form or you press a link) you have another javascript code, and you'll lose that timer.

If you cannot manage the timer in the server side as Pangea says you can try to load all the content with ajax. I mean, you have a first jsp when you start the timer and you have for example a container and with ajax calls you update the contents of this container and send data tothe server. The timer will be the same as long as you don't "leave" the page.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜