$(function() {
setInterval(function() {
$.get("refresh.php", function(result) {
$('#response').empty()
.hide()
.html(result)
$("#response").append(result)
.fadeIn("slow");
});
}, 5000);
});
実際、私のスクリプトは、refresh.php で 5 秒ごとにrefresh.phpにヒットします。mysql db からデータを取得し、次のようなテンプレートを作成します。
<table>
<tr><td>Name<td><td>$fetch['name']</td></tr>
</table>
firebugでrefresh.php送信応答を5秒後に1回だけチェックしましたが、すべてのブラウザで次のように結果が2回表示されます。
<table>
<tr><td>Name<td><td>$fetch['name']</td></tr>
</table>
<table>
<tr><td>Name<td><td>$fetch['name']</td></tr>
</table>