The simplest way to quickly resolve a jquery get cache problem is to introduce _jquery

Source: Internet
Author: User

Under the IE series, the $.get () method caches the return result when the URL address is fixed, causing unexpected problems. But under Firefox, it's not cached.

There are many ways to solve this problem, the most direct is to replace the $.get () method $.ajax (), and then configure Cache:false can be. I don't like $.ajax () cumbersome configuration, you can take the following simplest way to achieve:

After the data in $.get () is appended with a new random parameter, such as {data:mydata, Stamp:Math.random ()}, the data returned after the request is not cached because of the difference in each one.

Alternatively, the $.get () can be changed to $.post (), which can also be used to solve the problem.

A permanent solution is to set the global parameters, $.ajaxsetup ({cache:false}), so that the basic all GET request jquery will automatically add the _1948838 words of additional parameters, in general, similar to the solution above.

For example:
$.get ("Provincelistbycountryidhandler.ashx", {"CID": $drpCountry. Val (), "Time": New Date (). GetTime ()}, function (data , ReturnStatus) {})

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.