如果在服務器上發生更改,ajax每秒請求頁面自己的url,然後檢查textStatus
是否爲notmodified
,我試圖使頁面重新加載。如果在服務器上修改了重新加載頁面
setTimeout(function(){
$.ajax({
url : window.location.pathname,
dataType : "text",
ifModified : true,
success : function(data, textStatus) {
if (textStatus !== "notmodified") {
location.reload();
}
}
});
}, 1000);
然而,textStatus
總是success
檢查您的服務器的緩存標頭。 – SLaks 2013-02-15 14:41:52
我使用[Mongoose](http://code.google.com/p/mongoose/)作爲Web服務器。 – Theodor 2013-02-15 14:53:05