當我開始使用此代碼段自動刷新與阿賈克斯塊的衝突與發生「像」 ING活動上的BuddyPress:使用自定義自動刷新的js代碼,使衝突
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);
自動refereshing作品和我注意到一個一個前uto刷新,「像」ing作品,之後它不!控制檯也不會顯示任何關於它的錯誤。
任何幫助將不勝感激。