0

ここで、index.php で CKeditor を作成する方法を示します (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);
        ?>

このボタンを介してエディターの値を以下の ajax 関数に送信します。

( < a onclick="submit();" > Send < /a > == >これは ajax 関数を完全に呼び出します)

 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);
      }
      });
}

index2.php で値を取得しようとしました

   $textbox= $_POST['textbox'];

そしてそれはうまくいきませんでした。私もそれを経由して取得しようとしました

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

イットも機能しませんでした。この問題をどうしたらよいかわかりません。どんなアイデアでも大歓迎です

4

1 に答える 1

2

CKEditor に問題があり、それらの値に特殊文字が含まれている場合にその値を投稿しました。私の場合&nbsp;、エディタのコンテンツ内に a があったときに発生しました。不正なURLであるため、URLを「殺しました」?data=blabla&nbsp;..私はencodeURIComponent()を使用して、そのようなことが起こらないようにしました。

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

これがまさにあなたの問題かどうかはわかりませんが(今のところ;)、これも探したいと思うかもしれません.

于 2012-09-13T08:12:55.683 に答える