Question

I have problem sending content using CKEDITOR, I am send the content using AJAX

$("form#updateInfo").submit(function(){
    $("div#loading").html('<img class="loading" src="img/loading.gif" alt="" />');
    var content = CKEDITOR.instances['editor1'].getData();  
    $.ajax({
        url: "Sources/Ajax.php?act=updateInfo",
        type: "POST",
        data: "page="+$("input[name=page]").val()+"&content="+content,
        success: function(callback){
            $("div#loading").html('');
            if(callback != "OK"){
                $("span#cke_editor1").addClass("err");
                $("div#loading").html(error(callback));
            }else{
                $("div#loading").html(ok("Successfully update!"));
                $("div.n_error").remove();
                $("span#cke_editor1").removeClass("err");
                $("span#cke_editor1").val("");
            }
        }
    });
    return false;
});

Has u see the editor content is in the variable: CKEDITOR.instances['editor1'].getData(); I didnt understand why its dont save the all content, so I start debugging the code and I have understand the CKEDITOR break when he see ' / ". I tought it was magic quate that was on, but is not, maybe something got wrong in the php, so I remove the CKEDITOR and try to do it with a regular "textarea" and its work fine!

Examples: the content:

Hey guys I have drive alex's car today and it was so fun!

CKEDITOR's response: "Hey guys I have drive ale"

Textarea's response: "Hey guys I have drive alex\'s car today and it was so fun!"

I am desperate from this story maybe some of you guys may help me.

Thx!

Was it helpful?

Solution

That's not really the way to do POST variables, I think you might be mixing POST and GET.

Try this for the data format

url: "Sources/Ajax.php?act=updateInfo",
type: "POST",
data: { 
    page: $("input[name=page]").val(),
    content: content
},
success: function(callback){ ... }

How do you read them at the backend? $_POST? If not, I suspect that this really is a GET/POST issue and the value might get automatically transformed by the browser or server. What happens if you run CKEDITOR.instances['editor1'].getData(); in the developer console; do you see the complete text or the shortened version?

Also, what version of CKEditor do you use? Currently it's more common to see CKEDITOR.instances.editor.getData(); used.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top