Here is browser script to save "edit_body" field:
<script>
$(document).ready(function(){
$("#save_editable").click(function(){
var edit_body = $("#edit_body").html();
setTimeout(function(){
$.ajax({
url:'http://my-url.com/my_editor.php?id_to_update=123',
type:'POST',
data:{edit_body:edit_body},
success:function(data){
if(data=='1'){
alert('Saved');
}
}
});
},5000);
});
});
</script>
The server do next:
if(@$_POST["edit_body"]){
$id_to_update=intval($_GET['id_to_update']);
$edit_body=iconv('UTF-8', 'windows-1251', html_entity_decode($_POST["edit_body"], ENT_QUOTES, "utf-8"));
if(mysql_query(sprintf('update my_table set body="%s" where id="%s";',$edit_body,$id_to_update)){
print '1';
}
}
The problem is:
When "edit_body" contain a lot of text it successfully saves but not full content.
The weaker the browser is, the less text is saved (when more than 20 tabs opened).
In this case I've made setTimeout function with 5 sec delay. But it don't help some times..
How could I tell browser to wait for processing variable "edit_body" before Ajax post..?
How about using CKEditor's
How about using CKEditor's getData() method to get the document instead of jQuery's html() method? That way you're working with what the editor knows instead of what jQuery may or may not know at the time of the AJAX processing...
Yes!)
Thank You very MUCH!