Am not sure what is your ID. Let as assume the ID as example
Here is the code
jQuery(function($) {
$('#example').on('keyup', function() {
if(autosave_timer) {
clearTimeout(autosave_timer);
}
autosave_timer = setTimeout(save_by_ajax, 3000);
// after 3 second of keyup save_by_ajax function will execute
});
function save_by_ajax(){
var mid=$(this).attr('data');
var tid='#'+mid;
$(tid).jqte({"status" : false});
var content = $(tid).html();
$(tid).jqte({"status" : true});
$.ajax({
dataType:'JSON',
url: contentedit.ajaxurl,
type: 'POST',
data: {
action:"contentedit_ajax",
content: content,
mid:mid
},
});
}
});
your $putid
won’t be printed as it is not inside php tags. So either give the ID
manually or print in php correctly.
I’m clearing the function if the user keeps typing without 3 seconds gap. So this avoid server overload. NO ajax call be made until the user sits idle for 3 seconds