getJSON 缓存
来源:互联网 发布:企业级网络规划与设计 编辑:程序博客网 时间:2024/06/08 13:42
例1:
jQuery.getJSON("$!{Root}/a/a/s.ashx",{ID:"123456",Name:"john",random:Math.random()},function(responseText){}
例2:
"xxx.aspx?randID="+Math.random
例3:
"xxx.aspx?randID="+ escape(new Date())
2 将cache设为False
$.ajax不缓存版:
$.ajax({
type:"GET"
url:'test.html' ,
cache:false,
dataType:"html",
success:function(msg){
alert(msg);
}
});
3.在labels.html文件的顶部加入以下声明:
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
4.load函数不仅可以调用HTML,也可以调用script,比如labels.php,可以在php文件里使用header函数:
<?php
header("Cache-Control: no-cache, must-revalidate");
?>
5 使用post代替get方法。
使用Post方式需注意:
设置header的Context-Type为application/x-www-form-urlencode确保服务器知道实体中有参数变量. 通常使用XmlHttpRequest对象的SetRequestHeader("Context-Type","application/x-www- form-urlencoded;")。例:
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
参数是名/值一一对应的键值对,每对值用&号隔开.如 var name=abc&sex=man&age=18,注意var name=update.php?
abc&sex=man&age=18以及var name=?abc&sex=man&age=18的写法都是错误的;
参数在Send(参数)方法中发送,例: xmlHttp.send(name); 如果是get方式,直接 xmlHttp.send(null);
服务器端请求参数区分Get与Post。如果是get方式则$username = $_GET["username"]; 如果是post方式,则$username = $_POST["username"];
6 在服务端加 header("Cache-Control: no-cache, must-reva lidate");
7 在ajax发送请求前加上 xmlHttpRequest.setRequestHeader("If-Modified-Since","0");
8 在ajax发送请求前加上 xmlHttpRequest.setRequestHeader("Cache-Control","no-cache");
- getJSON 缓存
- getJSON缓存的解决方法
- $.getJSON的缓存问题
- $.getJson方法清除缓存
- $.getJSON()清理缓存
- $.getJson方法与缓存问题
- jQuery的getJSON缓存问题
- $.getJSON()存在缓存问题
- jQuery.getJSON的缓存问题的解决办法
- 解决jQuery.getJSON的缓存问题
- jquery.getJSON的缓存问题解决办法
- jQuery.getJSON的缓存问题的解决办法
- ie 下jQuery.getJSON() 缓存问题
- Jquery $.getJSON 在IE缓存问题
- $.getJSON()?
- $.getJSON
- $.getJSON
- getJson
- 深入分析Java ClassLoader原理
- 360 2013校园招聘笔试题(含参考答案)
- Linux多线程编程(不限Linux)
- sqlplus set用法
- C#阶乘
- getJSON 缓存
- 字节对齐
- Access restriction: The type XXXX is not accessible due to restriction on required library
- awk语法大全
- net-snmp-Using and loading MIBS
- MFC-CWinApp
- 定时任务crontab 详解
- GUID全局唯一标识符(GUID,Globally Unique Identifier)<转自百度百科>
- eclipse中项目小红叉(Target runtime Tomcat v6.0 is not defiend)