首 页 ASP ASP.NET PHP JSP Ajax DIV+CSS JavaScript XML C#
MySQL MSSQL Access Oracle Linux Server 电脑技巧 网络安全 建站经验 其它

Ajax的一些有用的小技巧

整理日期:2007年11月09日 【字体:


伊图教程网[www.etoow.com]
http://www.etoow.com/html/2007-11/1194584292.html
url += '?temp=' + Math.random();
在HTTP headers禁止缓存。如:
HTTP:
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
<meta http-equiv="expires" content="Thu, 01 Jan 1970 00:00:01 GMT" />
<meta http-equiv="expires" content="0" />
PHP:
header("Expires: Thu, 01 Jan 1970 00:00:01 GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
ASP:
Response.expires=0
Response.addHeader("pragma","no-cache")
Response.addHeader("Cache-Control","no-cache, must-revalidate")
JSP:
response.addHeader("Cache-Control", "no-cache");
response.addHeader("Expires", "Thu, 01 Jan 1970 00:00:01 GMT");
在XMLHttpRequest发送请求之前加上:
XMLHttpRequest.setRequestHeader("If-Modified-Since","0");
XMLHttpRequest.send(null);

IE下的reponseXML问题

使用responseXML时,IE下只能接受.xml为后缀的XML文件,如果不能以.xml文件为结尾的,则需要如下处理:
在服务器端声明是xml文件类型。如:
PHP:header("Content-Type:text/xml;charset=utf-8");
ASP:Response.ContentType = "text/xml";
JSP:response.setHeader("ContentType","text/xml");
利用responseText获取,然后封装成XML。
在AJAX应用上,JSON和JsonML是XML非常好的替代品。
Tags:
Ajax的一些有用的小技巧
'http://www.etoow.com/html/2007-11/1194584292.html
1
 
信息搜索
  
联系我们关于本站广告服务设为首页 收藏本站友情链接网站地图
Copyright © Etoow.com Inc. All Rights Reserved