最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Loading Gutenberg Blocks with Ajax is stripping away scripts - Stack Overflow

programmeradmin1浏览0评论

I'm successfully loading a custom post type's wp-content using ajax, but when it loads, a whole lot of the scripts are being stripped away.

fetch(ajax_object.ajax_url, {
    method: "POST",
    headers: {
        "Content-Type": "application/x-www-form-urlencoded",
    },
    body: new URLSearchParams({
        action: "uipp_get_button_content",
        button_id: button_id,
    }),
})
.then(response => response.json())
.then(data => {
    if (data.success) {
        revealContentWrapper.innerHTML = data.data.content;
        console.log("Loaded content:", data.data.content);
        reinitializeScripts(revealContentWrapper);  // Ensures scripts run properly
    } else {
        revealContentWrapper.innerHTML = `<p>Error: ${data.message}</p>`;
    }
})
发布评论

评论列表(0)

  1. 暂无评论