Ajax automatically clears cache or does not cache practices
Foreground HTML submission with JS script under Operation
Method One:
Add timestamp to Submission
That is modified at PostURL to:
var posturl= "/ashx/vote.ashx?id=" +obj+ "&optionid=" +sellist+ "&guid=" +new date (). gettime ();
+ "&guid=" +new date (). gettime ();
Plus this time, the problem is solved. Obviously Ajax returns the backend processing results in real time, which we aim to achieve. Ok
Method Two:
Using the Get URL with a random parameter can realize the Ajax automatic cache refresh.
Simple implementation Code
function Verify () {
Get the values in the page text box by using jquery
var url = "Ajaxserver?name=" + encodeURI (encodeURI ($ ("#username"). Val ());
Special handling of incoming values through Converturl, so that each data has a timestamp, resulting in a different xhttprequest request
url = converturl (URL);
Call the GET request method in jquery to pass the value to the server and define a callback function to display the data returned on the server side of the page
$.get (url,null,function (data) {
$ ("#result"). HTML (data);
});
}
Add timestamp to URL address, cheat browser, do not read cache
function Converturl (URL) {
Get time stamp
var timstamp = (new Date ()). valueof ();
To stitch timestamp information to a URL
url = "Ajaxserver"
if (Url.indexof ("?") >= 0) {
url = url + "&t=" + timstamp;
} else {
url = url + "? t=" + Timstamp;
}
return URL;
}