Ajax Caching problems

Source: Internet
Author: User
Tags copy window browser cache

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" &GT;QIWL (H9) </asp:ListItem>
<asp:listitem value= "KIWL" &GT;KIWL (H11) </asp:ListItem>
<asp:listitem value= "JIWL" &GT;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 = "";

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.