• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 276
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

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