[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 273
  • Last Modified:

the response of Ajax is not updated

Hi
I am developing a Asp.net Application using Ajax..
here i call tha Ajax:  url = "http://localhost:49674/test/LastPosition.aspx?name=test&userid=1"       
xmlHttp.open("GET",url,true);  
and my response will be like this:
<?xml version="1.0" encoding="UTF-8" ?>
- <NewDataSet>
- <Table>
  <TrackID>31546</TrackID>
  <UnitID>1010010033</UnitID>
  <Lon>144</Lon>
  <Lat>-37.5</Lat>
  <Speed>14</Speed>
  <_DateTIME>20101000000000</_DateTIME>
  <Heading>100</Heading>
  </Table>
  </NewDataSet>

but the problem is: if i launch 'http://localhost:49674/test/LastPosition.aspx?name=test&userid=1' in internet explorer  I get the last record inserted in database

but in javascript code when i receeive the ajax response i still get the old record..
please help
 there is my LastPosition.aspx code:
protected void Page_Load(object sender, EventArgs e)
    {
       name = Request.QueryString["name"];
       userid = Convert.ToInt16(Request.QueryString["userid"]);
       ds = this.busLayertracking.GetDeviceLastPosition(userid, name);
       XmlDocument doc = new XmlDocument();       
       doc.LoadXml(ds.GetXml());
       XmlDeclaration xmldecl;
       xmldecl = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
       XmlElement root = doc.DocumentElement;
       doc.InsertBefore(xmldecl, root);
       Response.Clear();
       Response.ClearContent();
       Response.ContentType = "text/xml";
       doc.Save(Response.OutputStream);
       Response.End();
    }

Open in new window

0
klay8
Asked:
klay8
1 Solution
 
David S.Commented:
It sounds like you've run into IE's tendency to cache AJAX responses.

One solution would be to add a pseudo-random string to the end of each URL:

url = 'http://localhost:49674/test/LastPosition.aspx?name=test&userid=1&'+(new Date()).getTime();

More information (be sure to read the first comment): http://weblogs.asp.net/pleloup/archive/2006/06/08/451583.aspx
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now