The solution of IE sending Ajax request to return the last result

Time:2021-6-17

Causes of the problem:

1. Only one Ajax request will be created under ie, and the response result will be put in the browser cache, which will be read from the cache the next time the Ajax request is called

In get mode, because the sending parameters and address are consistent, ie will get the data from the cache instead of requesting the server. In post mode, because of different parameters, this problem will not occur

2. The Ajax request will be reestablished every time the event is activated under Firefox

resolvent:

1: Add a random function after the page requested by Ajax. We can use the random time function

Add t = math. Random ()

For example: URL + “&” + “t =” + Math. Random(); Or new date(); Add “? timestamp=” + new Date().getTime();

2.

Copy codeThe code is as follows:
$.ajax({

type: “POST”,

async:false , / / set synchronization mode

cache:false , / / cache

url: url,

data:data,

success:function(data){
//Operation after successful return of value

}

});

The solution is cache:false

Recommended Today

Swift advanced 08: closure & capture principle

closure closurecanCapture and storageOf any constants and variables defined in their contextquote, this is the so-calledClose and wrap those constants and variablesTherefore, it is called“closure”Swift can handle everything for youCaptured memory managementOperation of. Three forms of closure [global function is a special closure]: a global function is a closure that has a name but does […]