ajax でブロックを自動更新するためにこのスニペットを使い始めると、buddypress での「いいね」アクティビティで競合が発生します。
myscr.js
jQuery( document ).ready( function() {
function update() {
jQuery("#notice").html('Updating...');
jQuery.ajax({
type: 'GET',
url: 'http://domain.com/activity',
data: "recentac=true",
//timeout: 5000,
success: function(data) {
jQuery("#recent-activities").html(data);
jQuery("#notice").html('');
window.setTimeout(update, 20000);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
jQuery("#notice").html('Error in connection');
window.setTimeout(update, 5000);
}
});
}
update();
});
そして、私はwp_enqueue_script
自分のスクリプトを印刷するために使用します:
function auto_refresh()
{
wp_enqueue_script('myscr', get_template_directory_uri().'/myscr.js', array("jquery"), '1.0', true );
}
add_action('wp_enqueue_scripts', 'auto_refresh', 99);
自動参照が機能し、自動更新の前に「いいね」が機能し、その後は機能しないことに気付きました! また、コンソールにはそれに関するエラーは表示されません。
どんな助けでも大歓迎です。