通过AJAX调用时Laravel不显示ckeditor或数据

时间:2019-07-31 16:51:38

标签: ajax laravel ckeditor

AJAX和laravel代码工作正常,所有数据都显示在文本区域中。当我尝试将CKeditor与textarea一起使用时,会发生问题。数据不显示。

删除CKEditor id会在textarea中显示数据,否则不会显示

AJAX代码

$('.code-edit-btn').on('click', function (){
var client_sel = $(this).data('id');
if (client_sel) {
    $.ajax({
        type: "GET",
        url: "/get_codes_data?id="+client_sel,
        success: function (res) {
            if (res) {
                $(".edit-lang-ans").empty(); 
// $('.edit-lang-ans').val(res.ans);
                $('.edit-lang-ans').val(JSON.stringify(res.ans));
            }
        }
    });
}

});

Laravel查看代码

<div class="form-group col-sm-12">
<label>Answer</label>
<textarea style="width: 100%; height: 200px; padding: 10px;" placeholder="Add Answer" name="ans" class=" edit-lang-ans"  id="article-ckeditor2"></textarea>
</div>

app.blade.php中的CK编辑器代码

<script>
        CKEDITOR.replace( 'article-ckeditor1' );
        CKEDITOR.replace( 'article-ckeditor2' );
</script>

即使使用CK编辑器也应显示数据。

0 个答案:

没有答案