Fetching Blog Content Data in my Edit Blog Modal Using Ajax

This is my HTML for Blog Content which is using ckeditor.

<div class="row">
    <div class="col-12">
       <div class="form-group mb-0">
          <label class="form-label" for="edit-blog-editor">Blog Content: <span class="validation">*</span></label>
          <textarea id="edit-blog-editor" name="edit-blog-editor"></textarea>
       </div>
    </div>
</div>

Ckeditor is initialised and is working for both add blog modal and edit blog modal.
But While fetching the data using ajax. i am facing an issue. Issue is that i am able to get my content as a response and in console.log as well.

Below is the code for fetching blog data using ajax

function decodeEntities(encodedString) {
    var textArea = document.createElement("textarea");
    textArea.innerHTML = encodedString;
    return textArea.value;
  }

  function fetchBlogContent(blogId) {
    $.ajax({
      url: "ajax-blog/fetch_blog_content.php",
      type: "POST",
      data: { eid: blogId },
      dataType: "text",
      success: function (content) {
        console.log("Received content:", content);
        CKEDITOR.instances["edit-blog-editor"].destroy();
        $("#edit-blog-editor").val(decodeEntities(content));
        CKEDITOR.replace("edit-blog-editor");
      },
      error: function (error) {
        console.log("Error fetching blog content:", error);
      },
    });
  }

console.log("Received content:", content); this code is returning the blog content data in console.
But After that i am not able to see the data in the text editor.

This is how i am fetching rest of the data

$("#blog-table").on("click", "#edit-blog-button", function () {
    let blogId = $(this).data("eid");
    $.ajax({
      url: "ajax-blog/fetch_blog.php",
      type: "POST",
      data: { blogId: blogId },
      dataType: "json",
      success: function (data) {
        // Populate modal fields
        $("#edit_blog_id").val(blogId);
        $("#edit-blog-title").val(data.title);
        $("#edit-blog-short-desc").val(data.short_description);
        $("#edit-blog-img-alt").val(data.image_alt);
        $("#edit-blog-posted-by").val(data.posted_by);
        $("#edit-blog-posted-on").val(data.posted_on);
        $("#edit-blog-meta-title").val(data.meta_title);
        $("#edit-blog-meta-desc").val(data.meta_description);
        $("#edit-blog-meta-key").val(data.meta_keywords);
        $("#edit-blog-category").val(data.category_slug);
        $("#edit-popular-blog").prop("checked", data.popular_blog === "yes");
        $("#edit-trending-blog").prop("checked", data.trending_blog === "yes");
        $("#edit-top-blog").prop("checked", data.top_blog === "yes");
        $("#edit-blog-slug-url").val(data.slug_url);

        fetchBlogContent(blogId);

        fetchCurrentImage(blogId);
      },
      error: function (error) {
        console.log("Error fetching blog details:", error);
      },
    });
  });

This is how i am fetching blog content using php

<?php

include("../include/config.php");

if (isset($_POST['eid'])) {
    $blogId = $_POST['eid'];

    $fetch_query = "SELECT blog_content FROM blogs WHERE id=?";
    $fetch_stmt = mysqli_prepare($conn, $fetch_query);

    if ($fetch_stmt) {
        mysqli_stmt_bind_param($fetch_stmt, "i", $blogId);
        if (mysqli_stmt_execute($fetch_stmt)) {
            $result = mysqli_stmt_get_result($fetch_stmt);
            $row = mysqli_fetch_assoc($result);

            echo json_encode($row);
        } else {
            echo json_encode(["error" => "Execution failed"]);
        }
    } else {
        echo json_encode(["error" => "Prepare failed"]);
    }

    mysqli_stmt_close($fetch_stmt);
    mysqli_close($conn);
}

I just want to show the data in ckeditor and i have no idea anymore how to resolve this.

i tried to initialise CK editor again. checked all the response up until putting data in the actual textarea. Which is not working at all.

I just want to fetch my data according to that id in ckeditor.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật