Jquery.load加载页面的速度较慢


Jquery .load loads page slowly

我使用的是以下代码:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">// <![CDATA[
$(document).ready(function() {
$.ajaxSetup({ cache: false }); // This part addresses an IE bug. without it, IE will only load the first number and will never refresh
setInterval(function() {
$('.container').load('dashboard.php');
}, 10000); // the "3000" here refers to the time to refresh the div. it is in milliseconds.
});
// ]]></script>
<div class="container"><h3>Loading Dashboard...</h3></div>

每隔X秒重新加载一个网页,但在第一次加载时,加载/显示似乎需要一段时间

如果我在地址栏(domain.com/dashboard.php(中键入页面名称,它会立即加载

有什么方法可以让它更快地装载吗?

setInterval在第一次调用函数之前等待定义的毫秒数。因此,在服务器端设置.container的内容(使用php(,而不是"Loading Dashboard…"或在页面加载上加载内容:

function reloadContainer() {
    $('.container').load('dashboard.php');
}
setInterval(reloadContainer, 10000);