ilhank
ilhank

Reputation: 148

Can not get the posted value of CKeditor in Php

Here how I created CKeditor in index.php(I am using it with CKfinder):

< textarea id="text" name="text" >

< /textarea >

       <?php
        include_once 'ckeditor/ckeditor.php';
        require_once 'ckfinder/ckfinder.php' ;
        $ckeditor = new CKEditor();
        $ckeditor->basePath  = 'ckeditor/' ;
        CKFinder::SetupCKEditor( $ckeditor, 'ckfinder/' ) ;
        $config['height'] = '300';
        $ckeditor->editor('text', $initialValue, $config);
        ?>

and submit the value of the editor via this button to the ajax function below:

( < a onclick="submit();" > Send < /a > == > this perfectly calls the ajax function)

 function submit()
    {
    var textbox= CKEDITOR.instances.text.getData();
    $.ajax({
            type: "POST",
            url: "index2.php",
            data: "textbox="+textbox,
            error: function(){

              alert('Error while loading');
          },
                success: function(data){
                $('#content').html(data);
      }
      });
}

In index2.php I tried to get the value as

   $textbox= $_POST['textbox'];

and it did not work. I also tried to get it via

   $textbox= stripslashes($_POST['textbox']) ;
   $textbox=mysql_real_escape_string($textbox);

İt also did not work. I do not know what to do with this issue. Any idea will be appreciated

Upvotes: 0

Views: 4523

Answers (1)

Gung Foo
Gung Foo

Reputation: 13568

I had a problem with CKEditor and posting it's values when those values contained special characters.. in my case it happened when a &nbsp; was inside the content of the editor. It "killed" the url since ?data=blabla&nbsp; is a malformed url.. i used encodeURIComponent() to make sure such things wouldn't happen.

https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/encodeURIComponent

not sure if this is exactly your problem (right now ;) but you might want to look for this too.

Upvotes: 2

Related Questions