我們有這段代碼來刷新我們擁有的DIV,包括一個請求數據的文件。目前的功能工作得很好,但我們希望mootools遷移。將函數從jQuery轉換爲Mootools
JS代碼:
<script>
jQuery.noConflict();
(function(jQuery) {
jQuery(function() {
jQuery(document).ready(function() {
// First initial refresh onLoad
jQuery(".wall_actions").fadeOut("fast").load("auto-refresh.php").fadeIn("fast");
// Use now with Interval - 10 seconds
var refreshId = setInterval(function() {
jQuery(".wall_actions").fadeOut("fast").load('auto-refresh.php').fadeIn("fast");
}, 5000);
jQuery.ajaxSetup({
cache: false
});
});
});
})(jQuery);
</script>
<div class="wall_actions">
<!-- other code -->
</div>
我們試圖用這種方法沒有成功遷移。
<script language="javascript">
var request = new Request({
url: 'auto-refresh.php',
method: 'get',
update: 'refresh-me',
onComplete: function(response) {
$('.wall_actions').set('html',response);
}
})
var doRefresh = function() {
request.send();
};
doRefresh.periodical(5000);
</script>
自動refresh.php
<?php
$page = "auto-refresh";
include "header.php";
$actions_array = $actions->actions_display(0, $setting['setting_actions_actionsperuser']);
$smarty->assign_by_ref('actions', $actions_array);
include "footer.php";
?>
我們如何使用jQuery的功能,使請求但MooTools的?
投票重新公開帳戶接受的答案。 –