Ajax caching problem under IE8/IE9
This article introduces to you the solution to the Ajax cache problem under IE8/IE9. It is very good and has reference value. Friends who are interested should take a look at it together
ajax introduction
AJAX stands for "Asynchronous Javascript And XML" (asynchronous JavaScript and XML), which refers to a web development technology for creating interactive web applications.
AJAX = Asynchronous JavaScript and XML (a subset of Standard Universal Markup Language).
AJAX is a technology for creating fast, dynamic web pages.
By exchanging a small amount of data with the server in the background, AJAX can enable asynchronous updates of web pages. This means that parts of a web page can be updated without reloading the entire page.
Let’s get to the point:
I am currently working on a login registration box for a website, using jquery on the front end. Since sign and login are not on separate pages, they appear in a pop-up box. So I decided to use ajax to implement the registration and login functions. I thought it would be smooth sailing, but I discovered a strange problem during the test.
There is basically no problem when testing with chrome, ff, and IE10. However, when running on IE8 and 9, it appears that I cannot log in after entering the correct user name and password. At first, I thought the session was lost and started complaining about the background framework.
But after patient debugging, I found that the session was not lost. I'm really worried now. Is it possible that I can't even register and log in after being around for so long? This makes me belittle myself and lament the various changes in life and the impermanence of things. After burning incense for 1/3 of the time, I decided to cheer up.
After carefully observing my code with few comments, I found that the url in $.ajax was a bit strange. Although the address is correct, the intuition of programmers and siege lions tells me that the two brothers IE8 and 9 may have cached my ajax on their own initiative. Thinking of this, my hands suddenly trembled, and I hurriedly added a timestamp after the URL.
//就像这样url:myurl+"?t="+(new Date).valueOf()
Then clear the cache and try again, success! You can log in normally.
After checking Baidu, it turns out that under IE8 9, when making an Ajax request, if it is the same as the previous request, the data will not be obtained from the server, but directly obtained locally.
In this way, in order to deal with the excessive enthusiasm of lower versions of IE, you can set its cache attribute to false (not tested) when using $.ajax,
cache:
It is required to be a parameter of Boolean type. The default is true (when the dataType is script, the default is false). If set to false, the request information will not be loaded from the browser cache.
Or set it globally (not tested)
//$.ajaxSetup() 方法设置全局 AJAX 默认选项。$.ajaxSetup({ cache: false });
Then you don’t have to worry about caching.
However, the cache is not set up to cause us trouble. After all, other browsers can use it normally. Therefore, it is necessary to set up a separate setting for IE8 9 to disable the information in the cache.
//jquery 1.9.0后取消了$.browserif($.browser.msie&&($.browser.version=="8.0"||$.browser.version=="9.0")){ //做处理 }
After 1.9.0, you can use $.support to judge
// IE6789,input元素的checked属性不能被拷贝// IE下,input被更换类型后,无法保持前一个类型所设的值if(!$.support.radioValue&&!$.support.noCloneChecked){ //做处理 }
The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.
Related articles:
The problem that IE8 cannot be refreshed every time when using ajax access
Ajax calls the restful interface to transmit Json format data Method (with code)
Ajax and cgi communication under Boa server (graphic tutorial)
The above is the detailed content of Ajax caching problem under IE8/IE9. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

DNS (DomainNameSystem) is a system used on the Internet to convert domain names into corresponding IP addresses. In Linux systems, DNS caching is a mechanism that stores the mapping relationship between domain names and IP addresses locally, which can increase the speed of domain name resolution and reduce the burden on the DNS server. DNS caching allows the system to quickly retrieve the IP address when subsequently accessing the same domain name without having to issue a query request to the DNS server each time, thereby improving network performance and efficiency. This article will discuss with you how to view and refresh the DNS cache on Linux, as well as related details and sample code. Importance of DNS Caching In Linux systems, DNS caching plays a key role. its existence

Title: Methods and code examples to resolve 403 errors in jQuery AJAX requests. The 403 error refers to a request that the server prohibits access to a resource. This error usually occurs because the request lacks permissions or is rejected by the server. When making jQueryAJAX requests, you sometimes encounter this situation. This article will introduce how to solve this problem and provide code examples. Solution: Check permissions: First ensure that the requested URL address is correct and verify that you have sufficient permissions to access the resource.

Build an autocomplete suggestion engine using PHP and Ajax: Server-side script: handles Ajax requests and returns suggestions (autocomplete.php). Client script: Send Ajax request and display suggestions (autocomplete.js). Practical case: Include script in HTML page and specify search-input element identifier.

How to solve the problem of jQueryAJAX error 403? When developing web applications, jQuery is often used to send asynchronous requests. However, sometimes you may encounter error code 403 when using jQueryAJAX, indicating that access is forbidden by the server. This is usually caused by server-side security settings, but there are ways to work around it. This article will introduce how to solve the problem of jQueryAJAX error 403 and provide specific code examples. 1. to make

PHPAPCu (replacement of php cache) is an opcode cache and data cache module that accelerates PHP applications. Understanding its advanced features is crucial to utilizing its full potential. 1. Batch operation: APCu provides a batch operation method that can process a large number of key-value pairs at the same time. This is useful for large-scale cache clearing or updates. //Get cache keys in batches $values=apcu_fetch(["key1","key2","key3"]); //Clear cache keys in batches apcu_delete(["key1","key2","key3"]);2 .Set cache expiration time: APCu allows you to set an expiration time for cache items so that they automatically expire after a specified time.

There is a close interaction between the CPU (central processing unit), memory (random access memory), and cache, which together form a critical component of a computer system. The coordination between them ensures the normal operation and efficient performance of the computer. As the brain of the computer, the CPU is responsible for executing various instructions and data processing; the memory is used to temporarily store data and programs, providing fast read and write access speeds; and the cache plays a buffering role, speeding up data access speed and improving The computer's CPU is the core component of the computer and is responsible for executing various instructions, arithmetic operations, and logical operations. It is called the "brain" of the computer and plays an important role in processing data and performing tasks. Memory is an important storage device in a computer.

Using Ajax to obtain variables from PHP methods is a common scenario in web development. Through Ajax, the page can be dynamically obtained without refreshing the data. In this article, we will introduce how to use Ajax to get variables from PHP methods, and provide specific code examples. First, we need to write a PHP file to handle the Ajax request and return the required variables. Here is sample code for a simple PHP file getData.php:

How to Export Browser Cache Videos With the rapid development of the Internet, videos have become an indispensable part of people's daily lives. When browsing the web, we often encounter video content that we want to save or share, but sometimes we cannot find the source of the video files because they may only exist in the browser's cache. So, how do you export videos from your browser cache? This article will introduce you to several common methods. First, we need to clarify a concept, namely browser cache. The browser cache is used by the browser to improve user experience.
