0

我的 fckeditor 在 Mozilla 中工作得很好。但它不会将文本保存到 Chrome 浏览器的数据库中。我通过 $,ajax 方法从 php 发送数据。这是PHP文件中的代码:

<div class="post_content"> Post Content <?

                                                        $sBasePath = $_SERVER['PHP_SELF'] ;
                                                        $sBasePath = "fckeditor/";

                                                        $oFCKeditor = new FCKeditor('FCKeditor1') ;
                                                        $oFCKeditor->Height = '400' ;
                                                        $oFCKeditor->BasePath   = $sBasePath ;
                                                        $oFCKeditor->Value      = '';
                                                        $oFCKeditor->Create(); 
                                                        ?>
                           </div>

这是我的javascript:

$(document).ready(function(){

            $("#add_new_post").submit(function() {

                var FCKGetInstance = FCKeditorAPI.GetInstance('FCKeditor1'); 

                var getText = FCKGetInstance.EditorDocument.body.innerHTML; 
                var StripTag = getText.replace(/(<([^>]+)>)/ig,"");


                var dataString = 'FCKeditor1='+ getText;


                        if(StripTag=='')
                         {
                            alert('Please enter Post Content .');

                         } else {
                             //alert(dataString);
                                $.ajax({
                                        type: "POST",
                                        url: "ajax_add_new_blog_post.php",
                                        data: dataString,
                                        cache: false,
                                        success: function(html){

                                                $("body").showMessage({

                                                      'thisMessage':    [html],

                                                      'autoClose':  true,

                                                      'className':  'tooltip',

                                                      'delayTime':  8000,

                                                      'displayNavigation':  false

                                                  });

                                                      setTimeout(function() {
                                                      window.history.back();

                                                  }, 3000);

                                        } 

                                    });

                             }

                    return false;

                    }); 

    });

这是我的 ajax_add_new_blog_post.php 代码:

$pagedetail = RTESafe($_REQUEST['FCKeditor1']);

                        $str="INSERT INTO posts set


                        post_text='".mysql_real_escape_string($pagedetail)."'";



                        $success = mysql_query($str);

                        if($success){

                                echo 'You have added post successfully!';

                            }else{

                                echo 'Adding post was not successful. Try again';
                            }

function RTESafe($strText) {

     $tmpString = trim($strText);

     $tmpString = str_replace(chr(145), chr(39), $tmpString);

     $tmpString = str_replace(chr(146), chr(39), $tmpString);

     $tmpString = str_replace("'", "&#39;", $tmpString);

     $tmpString = str_replace(chr(147), chr(34), $tmpString);

     $tmpString = str_replace(chr(148), chr(34), $tmpString);

     $tmpString = str_replace(chr(10), " ", $tmpString);

     $tmpString = str_replace(chr(13), " ", $tmpString);

     return $tmpString;

}
4

1 回答 1

0

如果可能的话,我的猜测是使用CKeditor。FCKeditor 已过时。

于 2012-09-19T19:48:56.903 回答