How jquery uses ajax to be cached by IE

Source: Internet
Author: User

Simple TestCodeTo load a text file using the Ajax class of jquery. If the IE file is saved slowly, the content in 1.txt is modified later, and the update still cannot be seen on the foreground.

<HTML xmlns = "http://www.w3.org/1999/xhtml">

<Script language = JavaScript src = "JS/jquery. js"> </SCRIPT>
<Script language = "JavaScript">
$ (Document). Ready (function (){
$. Ajax ({
URL: "1.txt ",
Type: 'get ',
Datatype: 'text ',
Success: function (data ){
Alert (data );
}
});

});

</SCRIPT>
</Html>

Solution

Method 1: Change the type to post, and set a parameter data: 'A = B 'randomly (you must set the parameter; otherwise, it will still be cached)

Method 2: type still uses get, but set cache: false

Method 3: Use ajaxsetup to globally set the cache in the get Method
$. Ajaxsetup ({
Cache: false // close Ajax Cache
});

Related Article

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.