【问题标题】:How to get content from CK Editor?如何从 CK Editor 获取内容?
【发布时间】:2015-07-12 18:07:18
【问题描述】:

我需要从 CK Editor 获取内容以将其放入 JQuery。

	
				<form action="php/showcomments.php" method="post" onsubmit="return false;" >
				<div class="text-cmt">
					<input id="tittle" name="tittle" type="text" placeholder="Comment Title" id="comm" required/>
				</div>
				<div class="text-cmt">
					<textarea id="msg"  ></textarea>
	
				</div>
				<div class="text-cmt">
					<input name="send"  type="submit" value="send">
				</div>
				</form>
					<script>
        CKEDITOR.replace( 'msg' );
    </script>

<script>
$(document).ready(function(){
	var g_id = "<?= $id; ?>";
	var u_id = "<?= userid; ?>";
	
  //  var comm = tinyMCE.editor.getContent();
	//tinyMCE.get('editor').getContent()
	  $("form").submit(function(){
		  var comm =  $("#tittle").val();
   	 $.ajax({
      url: 'php/showcomments.php', // form action url
      type: 'POST', // form submit method get/post
      data: {tittle: $("#tittle").val(),comm: comm, g_id: g_id,  u_id: u_id },
      dataType: 'html',
	  success: function(data)
	  {
		  alert(data);
      },
	 });
    });
});
</script>

【问题讨论】:

  • 请提供错误消息和实时页面 url,以便我们检查错误和 ckeditor 布局

标签: jquery ckeditor textarea


【解决方案1】:

你可以使用 ck 编辑器获取内容

CKEditor 3.6.x 的 JS

var editor = CKEDITOR.editor.replace('msg');

$('#send').click(function() {
    var value = editor.getData();
    // send your ajax request with value
    // profit!
});

用于 CKEditor 4.0.x 的 JS

$('#send').click(function() {
    var value = CKEDITOR.instances['DOM-ID-HERE'].getData()
    // send your ajax request with value
    // profit!
});

【讨论】:

    【解决方案2】:

    使用(您从数据库中获取的值)|安全。

    【讨论】:

      猜你喜欢
      • 2018-09-18
      • 1970-01-01
      • 1970-01-01
      • 2016-09-14
      • 1970-01-01
      • 1970-01-01
      • 2021-09-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多