Wednesday, February 27, 2013

Re: Redirect and execute after 2 seconds?

Thank you Bill! I dont know if I got you but if I do it with JavaScript I can't save the ID of the "missed" page, can I?
Because I want to save the page where no button was clicked to show it again at the end of the poll, so that the user gets another chance to answer this question.
 

Am Mittwoch, 27. Februar 2013 15:26:37 UTC+1 schrieb ke1g:
You must do this using JavaScript in the user's browser.  Look for time based events in JavaScript, including how to cancel them if a button is pressed.  The button should still probably submit to the Django server for recording, but you could simply record the fact that the correct (pseudo-)random id was visited.  You will have to record the GET for the time out case.  The time out handler can simple write to window.location to accomplish the "redirect" (which isn't really a redirect in the strict sense, since it doesn't occur as part of fetching a different page).  And that's JavaScript on the browser writing window.location, NOT anything within Django.

Bill

On Wed, Feb 27, 2013 at 9:01 AM, Maria <maria...@gmx.de> wrote:
Hi everyone! :)
 
I am working on a project for my studies, it is a web poll where you can only answer yes or no by clicking on buttons.
 
If the user clicked on one button, the result will be saved in a text-file and the user will be redirected to another page with a random id:
 
return HttpResponseRedirect ('/polls/'+str(sid))
 
If the user doesnt click on any button quickly enough, I want the page to redirect them after 3 seconds to another page with a random id AND i want to save the id of the question that wasnt answered.  How can I do it? I searched the web but only found the time.sleep function. As far as I understood, I cant use the sleep function because the site has to do other stuff while the 3 seconds pass.
 
I would be very thankful for any help on this!
 
Kind regards,
 
Maria

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment