2012-05-22 47 views
0

我有fckeditor在Mozilla中工作得很好。但它不會將文本保存到Chrome瀏覽器中的數據庫中。我通過$,ajax方法從php發送數據。這裏是PHP文件中的代碼:FCKeditor沒有在Chrome瀏覽器中將數據保存到數據庫中

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

} 
+0

當我使用警報(),在Mozilla它顯示FCKeditor1 =

DDDDDDDDD

,但在鉻,它顯示FCKeditor1 =   DDDDDDDDD – SAM

回答

0

我的猜測是使用CKeditor代替如果可能的話。 FCKeditor已過時。