I used Ajax to perform a name check. This is valid for the first time. But after the submission, I checked it again. The result is incorrect because of the cache of IE.
Copy codeThe Code is as follows:
Function verify (){
$. Ajax ({
// Issue for IE cache; timestamp = "+ new Date (). getTime ()
Url: "checkGroupName? Timestamp = "+ new Date (). getTime (),
Async: true,
Data: "groupName =" + $ ("# cn "). val () + "& groupTypeForDetail =" + $ ("# groupType "). val () + "& prefix =" + $ ("# p "). val (),
DataType: "html ",
Success: function (data ){
If (data = 1 ){
$ ("# Result" ).html ("<font color = 'green'> Group name [" + $ ("# p "). val () + $ ("# cn "). val () + "] Valid </font> ");
$ ("# Email "). val ($ ("# p "). val () + $ ("# cn "). val () + $ ("# emailHidden "). val ());
$ ('# Subdata'). removeAttr ("disabled ");
} Else if (data = 2 ){
$ ("# Result" ).html ("<font color = 'red'> Group name [" + $ ("# p "). val () + $ ("# cn "). val () + "] already existed. </font> ");
$ ('# Subdata'). attr ('Disabled', "true ");
} Else {
$ ("# Result" example .html ("<font color = 'red'> Group name can not be empty. </font> ");
$ ('# Subdata'). attr ('Disabled', "true ");
}
}
});
}
Principle:
Each request of Firefox will return to the server again to obtain the latest data, but IE will be different. It will cache the previous data, and only the first request will actually read the data from the server, as a result, ajax data will not be updated over time ....
Solution (collected from the Internet):
1. Add the header ("Cache-Control: no-cache, must-revalidate") on the server, or use the following combination to make it better:
Copy codeThe Code is as follows:
Header ("Expires: Sat, 1 Jan 2005 00:00:00 GMT ");
Header ("Last-Modified:". gmdate ("D, d m y h: I: s"). "GMT ");
Header ("cache-Control: no-cache, must-revalidate ");
Header ("Pragma: no-cache ");
2. Add xmlHttpRequest. setRequestHeader ("If-Modified-Since", "0") before ajax sends a request ");
3. Add xmlHttpRequest. setRequestHeader ("Cache-Control", "no-cache") before ajax sends a request ");
4. Add "? Fresh = "+ Math. random (); // Of course, the fresh parameter can be any one here
5. The fourth method is similar to the third method. Add "? Timestamp = "+ new Date (). getTime (); // This method is recommended. I use this method and I personally think it is more convenient.
6. Replace GET with POST: Not recommended