Ajax caching can reduce the unnecessary burden of frequent access to the server, but at the same time, it also brings some special business logic can not meet the problem.
For example:
You need a select Drop-down list at the front desk as an AJAX trigger entry, while the information returned by the server is presented to the page, and a logical operation is updated on the session or database for the actual things.
When the first switch option, that is, to submit the request is normal, but if you switch the same option because the browser cache reason, will not go to the server, the actual dynamic information obtained from the cache to fetch. The logic behind the scenes has not been taken. The code is as follows:
ASPX related code
Copy code code as follows:
<asp:dropdownlist id= "ddlproductlist" runat= "Server" >
<asp:listitem value= "" selected= "True" ></asp:ListItem>
<asp:listitem value= "NULL" >a</asp:ListItem>
<asp:listitem value= "QIWL" >QIWL (H9) </asp:ListItem>
<asp:listitem value= "KIWL" >KIWL (H11) </asp:ListItem>
<asp:listitem value= "JIWL" >JIWL (H15) </asp:ListItem>
<asp:listitem value= "NULL" >e interest rate there are acts K body insurance (city pelochely Bibroni) </asp:ListItem>
<asp:listitem value= "IIWL" >IIWL</asp:ListItem>
<asp:listitem value= "HIWL" >HIWL</asp:ListItem>
<asp:listitem value= "NULL" >e interest rate (a) K-Body insurance (a storage heavy) </asp:ListItem>
<asp:listitem value= "Kiwls" >KIWLS</asp:ListItem>
<asp:listitem value= "NULL" > Build e interest rate There are acts K-body </asp:ListItem>
<asp:listitem value= "ODIWL" >ODIWL</asp:ListItem>
<asp:listitem value= "JDIWL" >JDIWL</asp:ListItem>
<asp:listitem value= "HDIWL" >HDIWL</asp:ListItem>
<asp:listitem value= "NULL" > E interest rate has WAN </asp:ListItem>
<asp:listitem value= "Jdise" >JDISE</asp:ListItem>
</asp:DropDownList>
Aspx.cs Code
Copy code code as follows:
if (! IsPostBack)
{
Adding Client events for Doropdownlist
DDLPRODUCTLIST.ATTRIBUTES.ADD ("onchange", "Selectchange (This)");
}
Ajax.js Code
Copy code code as follows:
var request;
function Selectchange (obj) {
Createhttprequest ();
var url = "ajaxservice.aspxproduct=" + obj.value;
Request.open ("Get", url,true)
Request.onreadystatechange = resetrate;
Request.send ();
return false;
}
function Createhttprequest () {
if (window. ActiveXObject) {
Request = new ActiveXObject ("Microsoft.XMLHTTP");
else if (window. XMLHttpRequest) {
Request = new XMLHttpRequest ();
}
}
function Resetrate () {
if (request.readystate = = 4) {
if (request.responseText.substring (0,1) = "#") {
document.getElementById ("Systemerrormsg"). InnerHTML = request.responseText.substring (1);
document.getElementById ("rate"). InnerHTML = "";