Home Web Front-end JS Tutorial How to deal with the caching problem of jquery.getJSON under IE_jquery

How to deal with the caching problem of jquery.getJSON under IE_jquery

May 16, 2016 pm 05:39 PM
jquery cache


I encountered a problem in the project. Under Firefox, $.getJSON(); requested data and everything was normal, but under IE, $.getJSON(); only requested data once, and the second time it failed at all. The request is no longer sent. I found out after using fiddler to capture it. The request was not sent the second time and it was normal after I changed it to post

$.getJSON() has a caching problem. If the url it calls has been called before, the callback function will directly obtain the desired value in the cache instead of entering the background

The solution is as follows:

1. Make the URL different each time it is called.

Method: Add a random number to the parameter

Copy code The code is as follows:

$.getJSON("/Member/GetExercise.html" , { id: $("#Wareid").val(), isBool: loop, random:
Math.random() }, function (data) });

Copy code The code is as follows:

$.getJSON("/Member/GetExercise.html?random=Math.random ", { id: $("#Wareid").val(),
isBool: loop,}, function (data) });

Using new Date() can also be regarded as a random URL

Copy code The code is as follows:

?random=new Date().getTime()

2. Set cache to false

Copy code The code is as follows:

$.ajax({
type:"GET ",
url:'/Member/GetExercise.html',
cache:false,
dataType:"json",
success:function (data){
alert(data);
}
});
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1671
14
PHP Tutorial
1276
29
C# Tutorial
1256
24
How to view and refresh dns cache in Linux How to view and refresh dns cache in Linux Mar 07, 2024 am 08:43 AM

DNS (DomainNameSystem) is a system used on the Internet to convert domain names into corresponding IP addresses. In Linux systems, DNS caching is a mechanism that stores the mapping relationship between domain names and IP addresses locally, which can increase the speed of domain name resolution and reduce the burden on the DNS server. DNS caching allows the system to quickly retrieve the IP address when subsequently accessing the same domain name without having to issue a query request to the DNS server each time, thereby improving network performance and efficiency. This article will discuss with you how to view and refresh the DNS cache on Linux, as well as related details and sample code. Importance of DNS Caching In Linux systems, DNS caching plays a key role. its existence

The relationship between CPU, memory and cache is explained in detail! The relationship between CPU, memory and cache is explained in detail! Mar 07, 2024 am 08:30 AM

There is a close interaction between the CPU (central processing unit), memory (random access memory), and cache, which together form a critical component of a computer system. The coordination between them ensures the normal operation and efficient performance of the computer. As the brain of the computer, the CPU is responsible for executing various instructions and data processing; the memory is used to temporarily store data and programs, providing fast read and write access speeds; and the cache plays a buffering role, speeding up data access speed and improving The computer's CPU is the core component of the computer and is responsible for executing various instructions, arithmetic operations, and logical operations. It is called the "brain" of the computer and plays an important role in processing data and performing tasks. Memory is an important storage device in a computer.

jQuery Tips: Quickly modify the text of all a tags on the page jQuery Tips: Quickly modify the text of all a tags on the page Feb 28, 2024 pm 09:06 PM

Title: jQuery Tips: Quickly modify the text of all a tags on the page In web development, we often need to modify and operate elements on the page. When using jQuery, sometimes you need to modify the text content of all a tags in the page at once, which can save time and energy. The following will introduce how to use jQuery to quickly modify the text of all a tags on the page, and give specific code examples. First, we need to introduce the jQuery library file and ensure that the following code is introduced into the page: &lt

Use jQuery to modify the text content of all a tags Use jQuery to modify the text content of all a tags Feb 28, 2024 pm 05:42 PM

Title: Use jQuery to modify the text content of all a tags. jQuery is a popular JavaScript library that is widely used to handle DOM operations. In web development, we often encounter the need to modify the text content of the link tag (a tag) on ​​the page. This article will explain how to use jQuery to achieve this goal, and provide specific code examples. First, we need to introduce the jQuery library into the page. Add the following code in the HTML file:

Advanced Usage of PHP APCu: Unlocking the Hidden Power Advanced Usage of PHP APCu: Unlocking the Hidden Power Mar 01, 2024 pm 09:10 PM

PHPAPCu (replacement of php cache) is an opcode cache and data cache module that accelerates PHP applications. Understanding its advanced features is crucial to utilizing its full potential. 1. Batch operation: APCu provides a batch operation method that can process a large number of key-value pairs at the same time. This is useful for large-scale cache clearing or updates. //Get cache keys in batches $values=apcu_fetch(["key1","key2","key3"]); //Clear cache keys in batches apcu_delete(["key1","key2","key3"]);2 .Set cache expiration time: APCu allows you to set an expiration time for cache items so that they automatically expire after a specified time.

Getting Started with PHP APCu: Speed ​​Up Your Applications Getting Started with PHP APCu: Speed ​​Up Your Applications Mar 02, 2024 am 08:20 AM

PHP's User Cache (APCu) is an in-memory caching system for storing and retrieving data that can significantly improve application performance. This article will guide you through using APCu to accelerate your applications. What is APCu? APCu is a php extension that allows you to store data in memory. This is much faster than retrieving data from disk or database. It is commonly used to cache database query results, configuration settings, and other data that need to be accessed quickly. Installing APCu Installing APCu on your server requires the following steps: //For Debian/ubuntu systems sudoapt-getinstallphp-apcu//For Centos/RedHat systems sudoyumi

APCu Deep Dive: Revealing the Secrets of Caching APCu Deep Dive: Revealing the Secrets of Caching Mar 02, 2024 am 10:30 AM

Advantages of Using APCu APCu provides the following key benefits: Improved website speed: By caching data and pages, APCu reduces querying to the database and page generation time, thereby increasing overall website speed. Ease server load: Caching data and pages reduces demand on server resources, easing server load and preventing crashes during peak periods. Improved user experience: Faster website speed leads to a better user experience, increased conversion rates and lower bounce rates. Easy to integrate: APCu can be easily integrated into WordPress, Drupal, and other PHP applications without major code modifications. How APCu works APCu uses PHP memory to store data and pages. It stores the following data in cache

How to use caching in Golang distributed system? How to use caching in Golang distributed system? Jun 01, 2024 pm 09:27 PM

In the Go distributed system, caching can be implemented using the groupcache package. This package provides a general caching interface and supports multiple caching strategies, such as LRU, LFU, ARC and FIFO. Leveraging groupcache can significantly improve application performance, reduce backend load, and enhance system reliability. The specific implementation method is as follows: Import the necessary packages, set the cache pool size, define the cache pool, set the cache expiration time, set the number of concurrent value requests, and process the value request results.

See all articles