Using Ajax to do a name test, the first is effective, but submitted after the test again, the result is wrong, is due to the cache of IE reasons.
Copy Code code 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"). HTML ("<font color= ' Red ' >group name can not be empty.</font>");
$ (' #subData '). attr (' disabled ', "true");
}
}
});
}
principle:
Firefox every request will return to the server to get the latest data, but IE is not the same, it will cache the previous data, only the first request will be true to the server to read data, resulting in AJAX data will not update over time ....
Solutions (collected from the Web):
1, in the service End plus header ("Cache-control:no-cache, must-revalidate"); Or better with the following combination:
Copy Code code as follows:
Header ("Expires:sat, 1 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, in the AJAX send the request before adding Xmlhttprequest.setrequestheader ("if-modified-since", "0");
3, in the AJAX send the request before adding Xmlhttprequest.setrequestheader ("Cache-control", "No-cache");
4, after the Ajax URL parameters plus "? fresh=" + math.random (); Of course, the parameter fresh can be arbitrarily taken.
5, the fourth method is similar to the third, after the URL parameter plus "? timestamp=" + New Date (). GetTime (); Recommend this way, I use this, personally think more convenient.
6. Replace get with post: not recommended