i am writing a online text editor application, and i need to save data to mongo db every 3 minutes after last key press by user currently i am saving data after the textarea loses focus thats fine but i need to add more user friendly features so i need to add the above functionality but i cant figure out how to go about it i need a timer in jquery which can trigger the ajax call after 180 sec. Can anyone tell me which jquery function i can use to get the desired result. i am using on server side and mongo db as database.
Share
However, I’d use an approach that only saves when necessary, and in this case more often. The following example uses functions from Underscore.js.
This will save your data as soon as the user stops typing for at least 2 seconds, but not more than once every minute. Here’s a small example which saves every 2s after a modification every 10 seconds: http://jsfiddle.net/ThiefMaster/AagFC/