I am using a custom-html block with content:
<div id="server-01-box"></div>
<script>
fetch('//example.com/wp-admin/admin-ajax.php?action=aa-server-select&p=server-01')
.then(function (response) {
return response.text();
})
.then(function (body) {
var server_parser = new DOMParser();
var doc = server_parser.parseFromString(body, "text/html");
var ad_container = doc.querySelector('div');
document.querySelector('#server-01-box').innerHTML = ad_container.innerHTML;
});
</script>
When I inspect the page HTML, its injected there. However, my ad doesn’t show up. Is there a trick to getting the JS to run from within the sideblock plugin?