Created
September 8, 2021 14:08
-
-
Save slav123/73d18b9e43e7319340e7f3e96ba2719c to your computer and use it in GitHub Desktop.
simple javascript autosave
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var timeoutId; | |
$(document).on('keypress', '#overview', function () { | |
if (timeoutId) clearTimeout(timeoutId); | |
let brief = $(this).val() | |
let steps_id = $(this).data('id') | |
timeoutId = setTimeout(function () { | |
$.ajax({ | |
type: "POST", | |
url: base_url + 'client/save_brief', | |
dataType: "json", | |
data: {body: brief, id: steps_id}, | |
success: function (data) { | |
console.log('saved'); | |
}, | |
error: universalErrorHandler | |
}); | |
}, 750); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment