Autosave Functionality for Saving after Entering a Text in MVC

Consider we have a textarea with ID and Text 
  1. < div >   
  2.     @Html.HiddenFor(model = > model.MyNoteViewModels.ICTMyNoteId, new {@id = "ID"})  
  3.     @Html.TextAreaFor(model = > model.NoteViewModels.NoteItemText, new {@id = "Text", @onkeyup = "autosave()"})   
  4. < /div>   
  5.    
  6. <script>   
  7.     var autosave_timer = null;  
  8.     function save() {  
  9.         $.ajax({  
  10.             type: "POST",  
  11.             url: '@Url.Action("SaveNotes", "Note")',  
  12.             data: { nID: $('#ID').val() || 0, nText: $('#Text').val() },  
  13.             success: function (data) {  
  14.                 console.log("Notes saved");  
  15.             }  
  16.         })  
  17.     }  
  18.     function autosave() {  
  19.         if (autosave_timer)  
  20.         clearTimeout(autosave_timer);  
  21.         autosave_timer = setTimeout(save, 5000);  
  22.     }  
  23.    
  24. </script >  
We will be using the keyup function to save the Text using the ajaxcall. 
  1. public ActionResult SaveNotes(int nID, string nText)  
  2. {  
  3.    MyNoteViewModel model = new MyNoteViewModel();  
  4.    model.Id = nID;  
  5.    model.Text = nText;  
  6.    bool results = false;  
  7.    results = _myNMgr.SaveNoteText(model);  
  8.    return View(model);  
  9. }  
Controller will be having code to save the Text to database.