以下是我如何在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);
伊特也不起作用。我不知道该怎么处理这个问题。任何想法都将受到赞赏
当CKEditor的值包含特殊字符时,我在发布这些值时遇到了问题。。在我的情况下,当
在编辑器的内容中时,就会发生这种情况。它"杀死"了url,因为?data=blabla
是一个格式错误的url。。我使用encodeURIComponent()来确保这样的事情不会发生。
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/encodeURIComponent
不确定这是否正是你的问题(现在;),但你可能也想找这个。