如果AJAX响应中包含了如何渲染youTube订阅按钮。我使用了下面的功能,该功能可以正常工作,但它会在控制台日志中返回此错误:
SecurityError: Permission denied to access property "blablabla" on cross-origin object
function load_js() {
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://apis.google.com/js/platform.js';
head.appendChild(script);
}
$.ajax({
type: "POST",
url: ajaURL,
data: {
action: 'my_action',
},
success: function(response) {
// response = <div class="g-ytsubscribe" data-channelid="CHANNEL_ID" data-layout="default" data-count="default"></div>
$('.youtube-btn-container').html(response);
load_js();
}
});