日期:2014-05-16  浏览次数:20610 次

prototype ajax清除本地缓存

如果不清除本地缓存的话,即使调用Ajax.Request方法,浏览器会直接把缓存中的内容返回,而不去发送http请求。

?

function ajaxReq(){
var url = "ChatRoomServlet";
var param = "fname=${param.fname}&tname=${param.tname}";
new Ajax.Request(url,{
?method:"get",
?parameters:encodeURI(param),
?requestHeaders:['Cache-Control','no-cache','If-Modified-Since','0'],
??? onSuccess:function(httpObj){
??? ?$("chatarea").value = httpObj.responseText;
??? },
??? onFailure:function(httpObj){
??? }
});

?

setInterval("ajaxReq()",3000);//每隔3秒发一次异步http请求来局部刷新页面