Today, I modified a bug and used ajax to query data. In Google's browser, I can get the latest data. In IE, I got old data, but I cannot get the latest data, I found the IE cache again.
It is found that the ajax request uses the get method. The URL of each request is the same. The IE browser has a special place. If the URL of each request is the same, the existing data in the cache is displayed on the page, and the database is not queried again. Therefore, the old data is displayed each time.
Solution:
There is a way of thinking. We can make it different in the URL of each request. We can add a parameter, and the value of this parameter is different each time, so it is better to get rid of the timestamp.
Copy codeThe Code is as follows:
Url: '{0}/portal/articleManager/getContents? Id = {1} & date = {2} '. format (window. baseUrl, $ ("# id"). val (), new Date ())
Here, id is a useful parameter, and date is not processed.
According to the information, the post request can avoid this problem. POST is considered to be a variable access (the browser believes that the submission of POST must be changed ).
There is also a simpler way to set:
Copy codeThe Code is as follows:
Cache: false,
The premise is that the requested cache does not exist.