在客户端有一个HTML文件,用来提交输入信息,问题在于:每次按刷新时,发觉并不是整个页面重新被装载,好似是缓存中。

因为文本框中仍出现上次输入的值,只有在地址栏中按回车整个页面才重新装载,应当怎样避免此问题? 

1,在html里head区添加代码:

1
2
3
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="content-type" content="no-cache, must-revalidate" />
<meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT"/>

2,清除临时缓存

1
<body onLoad="javascript:document.yourFormName.reset()">

3,jquery ajax清除浏览器缓存的两种方法:

1)、通过$.ajaxSetup 设置属性cache:false,让ajax不调用浏览的缓存。

1
jQuery.ajaxSetup ({cache:false})

2)、在ajax的url后加上随机串来避免浏览缓存,例如:$.ajax({url:'test.php?'+parseInt(Math.random()*100000)})缓存。

相关文章:

  • 2021-11-21
  • 2021-08-18
  • 2021-08-04
  • 2021-11-08
  • 2021-05-08
  • 2021-08-19
  • 2022-02-07
  • 2022-01-09
猜你喜欢
  • 2021-11-20
  • 2021-12-02
  • 2022-12-23
  • 2021-08-08
  • 2021-11-21
  • 2021-11-21
  • 2021-11-21
相关资源
相似解决方案