Ajax cache in IE8/IE9: ie8ie9ajax Cache

Source: Internet
Author: User

Ajax cache in IE8/IE9: ie8ie9ajax Cache

Ajax Introduction

AJAX is "Asynchronous Javascript And XML" (Asynchronous JavaScript And XML), which is a Web page development technology used to create interactive web applications.

AJAX = Asynchronous JavaScript and XML (subset of standard General Markup Language ).

AJAX is a technology used to create fast dynamic web pages.

By performing a small amount of data exchange with the server in the background, AJAX can implement asynchronous updates on webpages. This means that you can update a part of a webpage without reloading the entire webpage.

Enter the subject:

Recently, in the login registration box for a website, jquery is used at the front end. Because the sign and login are not on a separate page, they are displayed in a pop-up box. Therefore, we decided to use ajax to implement the registration and login functions. I thought it would be smooth sailing, and I found a strange problem during the test.

When chrome, ff, and IE10 + are used for testing, there is basically no problem. However, when running on IE8 and 9, you cannot log on with the correct username and password. At first, I thought the session was lost and began to talk about the background framework.

However, after a patient debugging, we found that the session was not lost. Now, I am in a hurry. Is it impossible to get a registered login after such a long time? This allows me to be arrogant and lament the impermanence of life. Then, after being 1/3 fragrant, I decided to cheer up.

After carefully observing the code without a few comments, I found that the url in $. ajax is a bit strange. Although the address is correct, the intuition of programmers and siege lions tells me that IE8 9 May cache my ajax on their own. Think of this, his hands suddenly trembling, panic added a timestamp after the url.

// Like this url: myurl + "? T = "+ (new Date). valueOf ()

Then clear the cache and try again! You can log on normally.

I checked Baidu. It turns out that in IE8 9, if the Ajax request is the same as the previous request, no data will be obtained from the server, but directly from the local machine.

In this way, you can set the cache attribute to false (not tested) when using $. ajax to deal with the excessive enthusiasm of earlier versions of IE ),

Cache:

A Boolean parameter is required. The default value is true. If dataType is set to script, the default value is false. If it is set to false, request information is not loaded from the browser cache.

Or set it globally (not tested)

// $. AjaxSetup () method to set the global AJAX default options. $. AjaxSetup ({cache: false });

This eliminates the need to worry about caching.

However, the cache is not set to cause us trouble. After all, other browsers can work normally. Therefore, you must separately disable the information in the cache for IE8 9.

// Jquery 1.9.0 is canceled after $. browserif ($. browser. msie & ($. browser. version = "8.0" | $. browser. version = "9.0") {// processing}

After 1.9.0, you can use $. support to determine

// IE6789. The checked attribute of the input element cannot be copied/IE. After the input type is changed, the value of the previous type cannot be kept if (! $. Support. radioValue &&! $. Support. noCloneChecked) {// processing}

$. Support is mainly used inside jQuery, and it is not easy to use at all.

The above section describes the Ajax cache issue in IE8/IE9. I hope it will help you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.