I want to register if user has been on the page for a while (waiting for some content to load) or has just came to a page..
What would be the best way to do that? I am using Rails and jquery.
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
All users will “come” to the page but if you want to be alerted after they’re there for a specific amount of time you could set a timer to send an ajax request after a number of seconds.
For example, the following code would execute the function
informafter every 5 seconds. Informing you that the user is still waiting…The function
informwould be an AJAX request which informs the backend that the user is waiting. If you only want the request to fire once or after a number of runs stop firing then you could remove it withclearTimeout().If you want the timeout to only run while the user is waiting on a specific piece of content to load. You could have the
clearTimeout()execute when the content you expect will be delayed returns.You can find some more info on timeouts here.