In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you "example analysis of Ajax caching problems under IE8/IE9". The content is easy to understand and clear. I hope it can help you solve your doubts. Let the editor lead you to study and learn the article "sample analysis of Ajax caching problems under IE8/IE9".
Introduction to ajax
AJAX, namely "Asynchronous Javascript And XML" (Asynchronous JavaScript and XML), refers to a web page development technology that creates interactive web page applications.
AJAX = Asynchronous JavaScript and XML (a subset of the standard generic 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 update web pages asynchronously. This means that some part of the page can be updated without reloading the entire page.
Get to the point:
Recently, I am doing a login registration box for a website, and the front end uses jquery. Because sign and login do not appear on separate pages, but as a pop-up box. So I decided to use ajax to implement the registration and login functions. I thought it would be plain sailing, but I found a strange problem during the test.
There was almost no problem when testing with chrome, ff, and IE10+, but when running on IE8,9, it was impossible to log in by entering the correct user name and password. At first I thought session was missing, so I started complaining about the backstage framework.
But after patient debugging, it was found that session was not lost. This is killing me. Can't even get a registration done after such a long time? This makes me can't help but belittle myself and sigh that life is in a variety of ways and things are impermanent. After that, I decided to cheer up.
After taking a closer look at my code with few comments, I found that the url in $. Ajax is a little strange. Although the address is correct, the intuition of programmers and engineers tells me that the IE8 9 brothers may have cached my ajax affectionately. Thinking of this, my hands suddenly trembled and hurriedly added a time stamp after the url.
/ / like this url:myurl+ "? t =" + (new Date) .valueOf ()
Then clear the cache and try again, successful! You can log in normally.
Check Baidu, originally under IE8 9, when making an Ajax request, if it is the same as the previous request, it will no longer obtain data from the server, but directly from the local.
In this way, to deal with the excessive enthusiasm of the lower version of IE, you can set its cache property to false (untested) when using $.ajax.
Cache:
A parameter of type Boolean is required. The default is true (when dataType is script, the default is false). Setting to false will not load the request information from the browser cache.
Or set it globally (untested)
The / / $.ajaxSetup () method sets the global AJAX default options. $.ajaxSetup ({cache: false})
So you don't have to worry about caching.
However, the cache is not set up to cause us trouble, after all, other browsers can be used normally. Therefore, disable the information in the cache separately for IE8 9.
/ / cancel $.browserif ($.browser.msie & & ($.browser.version = = "8.0" | | $.browser.version = = "9.0") after jquery 1.9.0) {/ / do processing}
After 1.9.0, you can use $.support to determine
/ / the checked attribute of the IE6789,input element cannot be copied / / IE. After the input is changed, the value if (! $support.radioValue & &! $support.noCloneChecked) set by the previous type cannot be maintained {/ / do processing}
Support is mainly used for internal use of jQuery, and it doesn't feel good at all.
The above is all the contents of the article "example Analysis of Ajax caching problems under IE8/IE9". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.