Hi,
Using the editor component, what is the most appropriate way to load and save content from ajax ?
Is it .setContentHTML for the read but what about the write ? Unlike other components, there are no examples of using the dataAdapter with it…
Did see an example using dhtmlxAjax.getSync - is that the preferred method ? Couldn’t find a POST example though…
Thanks in advance,
Steve
Andrei
#2
Hi
// on client side
dhx4.ajax.post("server.php", "content="+encodeURIComponent(editor.getContent()), function(r){
var t = dhx4.s2j(r);
if (t != null && t.status == "good") {
console.log("success!")
} else {
...
});
// demo for server.php
<?php
// some extra security checks here...
$content = @$_REQUEST['content'];
if (you mayneed to escape value) $content = mysql_real_escape_string($content);
mysql_query("INSERT INTO .... VALUES (..., '".$content."')");
if (everything is ok) {
print_r("{status:'good'}");
} else {
....
?>
more ajax examples:
docs.dhtmlx.com/api__refs__dhtmlxajax.html