Smart AJAX autosave?

They have: 173 posts

Joined: Feb 2005

I have an autosave feature that, well... autosaves every minute. Now I could very well become the biggest abuser of my own feature. I currently have 8 windows open - I tend to just leave windows open for a long time. As a result, the javascript would be running every minute saving, creating unnecessary load on the server.

How could I make the autosave smart and only save if they are actively "working" with it? The only thing I can really think of is to have like a variable that sets to true whenever something happens, set to false whenever it saves, and only save when the var is true. Problem is, I have a lot of functions for events that I would need to attach it to... I'm sure I would miss it somewhere.

Any other ideas?

SonicMailer Pro - Professional mailing list manager & award-winning email marketing software
Download a FREE 30-day trial today!
Use coupon savemoreon4 and save 10%!

He has: 113 posts

Joined: Jul 2005

You havn't told us what you are 'autosaving'. Autosaving is generally a bad idea in web pages. Theres no way to really detect any inactivity without using javascript in combination with the mousemove event. The only way would be as you suggested, with a flagging variable.

I wouldn't reccommend autosaving.

They have: 173 posts

Joined: Feb 2005

Neutron2k;211500 wrote: You havn't told us what you are 'autosaving'. Autosaving is generally a bad idea in web pages. Theres no way to really detect any inactivity without using javascript in combination with the mousemove event. The only way would be as you suggested, with a flagging variable.

I wouldn't reccommend autosaving.

As of now, I have applied the onmouseup event to the "content" div. That should be sufficient to see if they are in fact "actively working" within the page.

SonicMailer Pro - Professional mailing list manager & award-winning email marketing software
Download a FREE 30-day trial today!
Use coupon savemoreon4 and save 10%!

He has: 113 posts

Joined: Jul 2005

I Can't see how that is going to make the system think the user is active. The better move would be to apply the event to the bodys onmousemove handler. That way it is kept alive as long as the user is moving the mouse which is much more likley than the user continually clicking.

They have: 173 posts

Joined: Feb 2005

Neutron2k;211642 wrote: I Can't see how that is going to make the system think the user is active. The better move would be to apply the event to the bodys onmousemove handler. That way it is kept alive as long as the user is moving the mouse which is much more likley than the user continually clicking.

Because of the way it works, I can't imagine 60 seconds passing by without the user clicking within my content div.

SonicMailer Pro - Professional mailing list manager & award-winning email marketing software
Download a FREE 30-day trial today!
Use coupon savemoreon4 and save 10%!

Jack Michaelson's picture

He has: 1,733 posts

Joined: Dec 1999

Last summer I've made an educational website where scholars can make assigments and do tests. I've created an onblur autosave for *every* input type and textarea. I think that's what you're looking for?

Shakespeare: onclick || !(onclick)

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.