In the latest project, Ajax is used to import and update data in batches. The first time the data is submitted normally, the same order is submitted later. The Order has been processed, but the interface still prompts that the order has not been processed.
I found the cause, which was originally caused by Ajax cache problems.
The solution is as follows:
1,Add the header ("cache-control: No-cache, must-revalidate") on the server (such as in PHP)
2,Add anyajaxobj. setRequestHeader ("If-modified-since", "0") before Ajax sends a request ");
3,Add anyajaxobj. setRequestHeader ("cache-control", "No-Cache") before sending a request through Ajax ");
4,Add "? Fresh = "+ math. Random (); // Of course, the fresh parameter can be any one here
5,The fifth method is similar to the fourth method. Add "? Timestamp = "+ new date (). gettime ();
6,Replacing get with post: Not recommended
Use the fourth solution in the project:Math. Random (). After this random parameter is added, the system is normal.
$. Ajax ({
Type: "Get ",
Async: False ,
URL: "../handler/k3importdeliveryhandler. ashx? Orderid = "+ Text [I] + '& time =' + math. Random (),
Beforesend: Function (XMLHttpRequest ){
$ ('# Loading'). Show ();
$ ('# Txtlog '). val ($ ('# txtlog '). val () + '[processing Order' + Text [I] + '...] \ n ');
},
Success: Function (Data, textstatus ){
$ ('# Txtlog'). Val ($ ('# txtlog'). Val () + Data + '\ n ');
},
Complete: Function (XMLHttpRequest, textstatus ){
$ ('# Loading'). Hide ('low ');
},
Error: Function (){
}
});