无法使用ckeditor传递文本值

时间:2013-07-08 19:47:18

标签: php javascript ajax

我正在尝试使用ckeditor发送文本值。但我没有从ckeditor获得任何价值。如果我使用HTML,那么我得到的价值。我不知道我做错了什么。请有人帮助我。 这是我的代码:

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

1 个答案:

答案 0 :(得分: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;
};
相关问题