2015-07-12 3 views
-3

Мне нужно получить контент из редактора CK, чтобы поместить его в JQuery.Как получить контент от CK Editor?

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

<script> 
 
$(document).ready(function(){ 
 
\t var g_id = "<?= $id; ?>"; 
 
\t var u_id = "<?= userid; ?>"; 
 
\t 
 
    // var comm = tinyMCE.editor.getContent(); 
 
\t //tinyMCE.get('editor').getContent() 
 
\t $("form").submit(function(){ 
 
\t \t var comm = $("#tittle").val(); 
 
    \t $.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', 
 
\t success: function(data) 
 
\t { 
 
\t \t alert(data); 
 
     }, 
 
\t }); 
 
    }); 
 
}); 
 
</script>

+0

просьба сообщить сообщение об ошибке, а также жить URL страницы, чтобы мы могли проверить на ошибки и CKEditor макете не –

ответ

3

Вы можете получить содержимое редактора ск с помощью

JS для CKEditor 3.6.x

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

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

JS для CKEditor 4.0.x

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

получить от текстового поля, но из CKEditor –

+0

Обновленный код для ckeditor –

+0

спасибо :) вы помогите мне :) –

Смежные вопросы