---
title: "ajax请求时的缓存的问题"
author: "yaofeng911"
date: "2009-05-05T17:35:14Z"
tags: ["Ajax", "IE", "jQuery", "json"]
categories: ["Web前端"]
slug: "ajax"
draft: false
lastmod: "2009-05-06T12:49:14Z"
id: 379705
url: "https://yaofeng911.iteye.com/blog/379705"
---

ajax请求同一个url地址时，如果发现url地址没有变而缓存里有就会直接去取值，不会再去请求服务器。这种情况会在不同的机器不同的IE上各有不同，解决的方式是在ajax请求的地址里加上一个随机的参数例如(jQuery)：

 

```
$.getJSON(path+"/library/structuresView.do?num=1&structCount="+customColumnNum*rowNum+"&datetime="+(new Date()).getTime(), "", function(json){alert(json)})

$.ajax({url: path+"/library/structuresPropertyPreview.do?fetch=all&random="+Math.random(),
type: 'GET', 
success: function(data){alert(data)} });
```

 

 

只要ajax每次请求的地址不一样就可以的。