Ajax bizare

Giganews Newsgroups
Subject: Ajax bizare
Posted by:  GTi (tunl…@gmail.com)
Date: 29 Sep 2006

I have a bizare Ajax POST problem.
I use Ajax POST to send data to the server.
The server get the POST and answer back.
BUT if I POST the data once again I recieve the same answer that the
first post give me, even if the answer is different. I have used HTTP
Analyser Std V2.1.1.15 and I see that the answer is different. But the
Ajax .responseText is the same as the first POST. It looks like it use
the cached respons.
In the RFC the client should never use the cache if it is a POST.
And to make sure I have added a new serial=xxxx in the POST URL for
eatch requests.
But still get the same result as the first POST into the JavaScript
(but the respons from the server IS different).

Here is the server responses from HTTP Analyser:
----------------------------------------
(Request-Line):POST /page.aspx?EditMaster=0&serial=1159541629765
HTTP/1.1
Host:127.0.0.1
User-Agent:Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.7)
Gecko/20060909 Firefox/1.5.0.7
Accept:text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language:nb
Accept-Encoding:gzip,deflate
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive:300
Connection:close
Content-Type:application/x-www-form-urlencoded
Cache-Control:post-check=0, pre-check=0, no-cache
Pragma:no-cache, no-cache
Content-Length:3695
Cookie:WebSelectTabWorkShiftWebTab2=1; WebSelectTabRealTPIWebTab2=2
-----------------------------------------
(Status-Line):HTTP/1.1 200 OK
Server:Microsoft-IIS/5.1
Date:Fri, 29 Sep 2006 14:53:49 GMT
X-Powered-By:ASP.NET
Connection:close
X-AspNet-Version:2.0.50727
ABB:MES
Set-Cookie:ASP.NET_SessionId=kfrv5c55kbeefemshid2ki45; path=/; HttpOnly
Cache-Control:no-cache
Pragma:no-cache
Expires:-1
Content-Type:text/html; charset=utf-8
Content-Length:239

Here is the JavaScript Code:
function AjaxFormPostItMakeRequest(url, data)
{
[snippet .. AjaxForm = new XMLHttpRequest() ... blabla]
AjaxForm.onreadystatechange = AjaxFormPostItalertContents;
AjaxForm.open('POST', url, true);
AjaxForm.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded");
AjaxForm.setRequestHeader("Content-length", data.length);
AjaxForm.setRequestHeader("Connection", "close");
AjaxForm.setRequestHeader("Cache-Control", "no-store, no-cache,
must-revalidate");
AjaxForm.setRequestHeader("Cache-Control", "post-check=0,
pre-check=0");
AjaxForm.setRequestHeader("Pragma", "no-cache");
AjaxForm.send(data);
}

function AjaxFormPostIt(obj)
  {
  var getstr = '';
  [ snippet - get all the post elements]
  var timestamp = new Date().getTime();
  var url = '/page.aspx?EditMaster=0&serial=' + timestamp;
  AjaxFormPostItMakeRequest(url, getstr);
  }

Anyone can help me out here - please?
GTi

Replies