jquery.autosave.js
$("input").autosave({url:"/save",success:function(){},error:function(){});
That will bind a "change" event handler to all input elements, and post their values to the "/save" url each time the input value has changed.
Options
You can pass any of these options to the .autosave() function:
Option | Type | Default | Description |
---|---|---|---|
url | string | null | Url use to post ajax data. |
event | string | change | Event that causes the plugin to send data to your url. See jQuery.bind for options. |
data | object | null | Object that holds all data that will be posted back to the url when the event is fired. You can set global default values to be sent here. All data-* attribute values end up here, minus "data-" (e.g. "data-id" becomes "id"). |
debug | boolean | false | Will stop any requests from being performed and will console.log the data variable inside of the autosave library |
type | string | html | You can now specify the dataType you are expecting (xml, json, script, or html) |
success | function | function(data,$jqueryElement){} | Callback used when data was saved successfully. The data returned from the ajax request, plus the jQuery element are passed to this method. |
error | function | function(error,$jqueryElement){} | Callback used when data was not saved, or there was an error. The jQuery element is passed to this method. |
before | function | function($jqueryElement){} | Callback called just before a request is sent to the server. The jQuery element is passed to this method. |