AJAX Autosave functionality

前端 未结 8 1642
旧巷少年郎
旧巷少年郎 2020-12-07 09:54

What\'s the best javascript library, or plugin or extension to a library, that has implemented autosaving functionality?

The specific need is to be able to \'save\'

8条回答
  •  粉色の甜心
    2020-12-07 10:32

    Autosave should be pretty simple to implement, and you could use one of the major frameworks like jquery or mootools. All you need to do is use window.setTimeout() once your user edits something that should be autosaved, and have that timeout call the javascript frameworks standard AJAX stuff.

    For example (with jquery):

    var autosaveOn = false;
    function myAutosavedTextbox_onTextChanged()
    {
        if (!autosaveOn)
        {
            autosaveOn = true;
    
            $('#myAutosavedTextbox').everyTime("300000", function(){
                 $.ajax({
                     type: "POST",
                     url: "autosavecallbackurl",
                     data: "id=1",
                     success: function(msg) {
                         $('#autosavenotify').text(msg);
                     }
                 });
            }); //closing tag
        }
    }
    

提交回复
热议问题