【问题标题】:how to update textarea value in php ajax with ckeditor?如何使用ckeditor更新php ajax中的textarea值?
【发布时间】:2017-06-02 04:10:08
【问题描述】:

我在我的网站中使用 CkEditor。

当我在 textarea 字段中使用 php ajax 更新数据库中的数据但数据未显示 textarea 字段时。但是没有 ckeditor 我的代码运行完美。请帮帮我!!

【问题讨论】:

  • 能否出示相关代码
  • 请添加您尝试过的代码
  • $(document).on('click', '.update', function(){ var user_id = $(this).attr("id"); var action = "Fetch Single Data "; $.ajax({ url:"action.php", method:"POST", data:{user_id:user_id, action:action}, dataType:"json", success:function(data) { $('.崩溃').collapse("show"); $('#desc').val(data.desc); $('#uploaded_image').html(data.image); $('#hidden_​​user_image').val (data.user_image); $('#button_action').val("Edit"); $('#action').val("Edit"); $('#user_id').val(user_id); } }); });
  • ck编辑器数据你需要保存一个隐藏文本并使用这个文本保存数据

标签: php mysql ajax


【解决方案1】:

你需要使用CkEditor设置数据方法documentation

CKEDITOR.instances.editor1.setData(data.desc);

【讨论】:

  • 在哪里使用 CKEDITOR.instances.editor1.setData(data.desc);代码
  • 替换这一行 $('#desc').val(data.desc);用这一行 CKEDITOR.instances.editor1.setData(data.desc); @山姆
  • 如果我的回答有用,请用绿色勾号标记,这对将来的用户参考很有用。 @山姆
  • 但是我还有另一个问题......当我提交数据时......数据保存在数据库中第二次而不是第一次提交。
  • 我认为这似乎是新问题。这样您就可以详细地发布新帖子。所以人们会帮助你和我@sam
【解决方案2】:
$.ajax({
    type: "POST",
    url: "function/fetch.php",
    dataType: "html",
    data: {updateEmailTemplateID: id,UserID:UserID },
    success: function (response) { 
        response = JSON.parse(response);
        $('input[name="Updatetitle"]').val(response.title);
        CKEDITOR.instances.editor2.setData(response.description);
        $('#Update').modal('show');
    }
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-12-15
    • 1970-01-01
    • 2011-07-06
    • 2015-05-06
    • 2021-12-14
    • 1970-01-01
    • 2016-03-18
    相关资源
    最近更新 更多