2013-07-08 35 views
0

我正在嘗試使用ckeditor發送文本值。但是我沒有從ckeditor那裏得到任何價值。如果我使用HTML,那麼我得到的價值。我不知道我做錯了什麼。請有人幫助我。 這裏是我的代碼:無法使用ckeditor傳遞文本值

<textarea class="ckeditor" id="text" name="text"><?php echo $article['text'];?></textarea> 

<input id="articleSUBMIT" type="submit" value="submit" onClick="return articlePOST();"/> 

這裏是我的Ajax代碼:

function articlePOST(){ 
    //Is the form valid? 
    if($("#article").valid()) { 
     var srt = $("#article").serialize(); 
     $.ajax({ 
      type: "POST", url: "ajax/article.php", data: srt, 
      beforeSend: function(){$("#loading").show("fast");}, 
      complete: function(){$("#loading").hide("fast");}, 
      success: function(html){$("#article").html(html);$('#uploader-container').html('');} 
      }); 
    } 
    return false; 
}; 

回答

0

使用此保存觸發所有頁面的編輯器實例:

function saveEditorTrigger() 
{ 
    for (instance in CKEDITOR.instances) CKEDITOR.instances[instance].updateElement(); 
} 

調用此函數提交之前。像這樣:

function articlePOST(){ 
// Update editor 
saveEditorTrigger(); 

//Is the form valid? 
if($("#article").valid()) { 
    var srt = $("#article").serialize(); 
    $.ajax({ 
     type: "POST", url: "ajax/article.php", data: srt, 
     beforeSend: function(){$("#loading").show("fast");}, 
     complete: function(){$("#loading").hide("fast");}, 
     success: function(html){$("#article").html(html);$('#uploader-container').html('');} 
     }); 
} 
return false; 
}; 
+0

Thanks @MahanGM it's working .. –