Several solutions to jquery cache problems _ jquery

Source: Internet
Author: User
In ie browsers, the general ajax methods are cache = true. Below are a few good solutions. If you are interested, refer. the default value of the cache parameter is true for the load method. Especially in IE browsers, the average ajax method is cache = true!
Solution:
1. Use the. ajax method and set the cache parameter to false.

The Code is as follows:


$. AjaxSetup ({cache: false });
$ (Fucntion ({
$. AjaxSetup ({cache: false });
}))


Run the load method before each execution. Note that it cannot be set as a global attribute.

You can write a method to reference this method every time you open the page.

2. Modify the load method and load method in jquery. js to call. ajax and add cache: false.
3. Add the random number parameter after the link you requested to make the ajax request think it is a different link address
4. Use POST instead of GET. The browser does not cache POST.
I used the method of adding a random number: var url = "memberlog_showLogComment.action? Logid = "+ logid +" & random = "+ Math. random ();
$ ("# Comment "). load (url); you can execute each click. the load method can use post instead of get: $ ("# comment "). load ("memberlog_showLogComment.action", {"logid": logid });

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.