Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to resume timer on ajax requests #23

Open
bhavikji opened this issue Sep 5, 2017 · 3 comments
Open

How to resume timer on ajax requests #23

bhavikji opened this issue Sep 5, 2017 · 3 comments

Comments

@bhavikji
Copy link

bhavikji commented Sep 5, 2017

hello, I have implemented this plugin and it is working like but when I am requesting via ajax the timer is not resuming and continue to countdown the seconds because of idle session

I have further looked into stack overflow and tried couple of things as suggested but that too didn't worked for me.
1st I have tried the answer which I got here
https://stackoverflow.com/questions/35143230/jquery-ajax-aborted-in-laravel-5-2-using-jquery-idle-timeout

ie., either commenting out the ajax timeout or call it on ajax success but there I got timer appended into existing timer instead of resuming the exisitng timer and thus logging out after the completion of 1st timer.

https://stackoverflow.com/questions/31888343/reset-idletimeout-counter-between-ajax-post

2nd I tried to call it on ajaxSuccess function but that too gave me the same above mentioned problem

Now, I would be thankful If you help me out to solve this issue I want to resume the timer like it is resuming on click or reload of the page after every ajax call.

@topherZa
Copy link

topherZa commented Feb 2, 2018

@wmtoscar
Due to my own ignorance (I'm sure) I ended up reorganizing the code into a modular fashion instead of it being in an object literal, then exposed a new 'Resume' method which just has the code for the on click event for the popup. I just call that method in an ajaxSuccess.

I'm sure it could have been done in an easier way instead of how I did it but for the life of me I couldn't figure out how to expose another 'resume' method to be called externally in the object literal way the code has been rewritten originally.

If you want/still need, I'll post the code here.

Nevermind - I just forked and uploaded it. I'm sure you can find it on my profile.

@bhavikji
Copy link
Author

bhavikji commented Feb 5, 2018

yeah I need that.

@topherZa
Copy link

topherZa commented Feb 5, 2018

@wmtoscar

Here's a link to the repo with my changes:
https://github.com/topherZa/jquery-idle-timeout

I just happened to look at other forks though and saw that someone else has already done this by just exposing the resume method in a way that I'm sure I tried (but I guess not :( ). Maybe that one would work better for you since there are fewer changes to the original library so reducing the chance for new bugs being created:
jfren484@656a805

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants