Ajax bizare

G

GTi

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
 
T

Tom Cole

GTi said:
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

You need to set some Content Headers when your server resource replies:

Cache_control: no-cache
Pragma: no-cache

This will tell the UA to always get a new response, not use one from
cache.
 
T

Tom Cole

Tom said:
GTi said:
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

You need to set some Content Headers when your server resource replies:

Cache_control: no-cache

Make that Cache-Control (dash, not underscore)...Sorry.
 
V

VK

Tom said:
Cache-Control: no-cache
Pragma: no-cache

This will tell the UA to always get a new response, not use one from
cache.

A small correction: the last one (Pragma) doesn't handle the UA's cache
mechanics. It instructs the intermediary servers do not serve the
request from their proxies but to re-request the source server (where
understood of course).
 
G

GTi

VK said:
A small correction: the last one (Pragma) doesn't handle the UA's cache
mechanics. It instructs the intermediary servers do not serve the
request from their proxies but to re-request the source server (where
understood of course).

Is't it already here:

(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
 
V

VK

Cache-Control: no-cache
Is't it already here:

(Status-Line):HTTP/1.1 200 OK
Server:Microsoft-IIS/5.1
<snip>

Firefox has POST problems with some versions of IIS, because some IIS
are using a non-standard packets split-off in response (if not
patched). IE likes it, Firefox wants it in the conventional way. Search
bugzilla.mozilla.org for "IIS server POST packet length", I don't have
the exact bug URL. I'm not saying it is the reason: just one more
direction to look at. Maybe c.i.w.a.h. and mozilla.org can be more
helpful.
 
G

GTi

VK said:
<snip>

Firefox has POST problems with some versions of IIS, because some IIS
are using a non-standard packets split-off in response (if not
patched). IE likes it, Firefox wants it in the conventional way. Search
bugzilla.mozilla.org for "IIS server POST packet length", I don't have
the exact bug URL. I'm not saying it is the reason: just one more
direction to look at. Maybe c.i.w.a.h. and mozilla.org can be more
helpful.

Thanks VK, I will try searching for it at mozilla.org.
However I got the same problem with IE !
 
G

GTi

OK, Ajax IS now reported fit :)
I tested it a little more and added a alert in my function:

function AjaxFormPostItalertContents()
{
if(AjaxForm.readyState == 4)
{
if (AjaxForm.status == 200)
{
var result = AjaxFormPostItHTTPRequest.responseText;
alert(result);
document.getElementById('PostInformationWindow').innerHTML =
result;
}
else
{
alert('There was a problem with the request.');
}
}
}

In the alert window I did see that the values from the server was
changed,
but NOT in the 'PostInformationWindow' <div>
How come ?


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
 
V

VK

GTi said:
In the alert window I did see that the values from the server was
changed,
but NOT in the 'PostInformationWindow' <div>
How come ?

Nasty gobblins in your computer? :)
That must be some communication problem with 'PostInformationWindow',
without an actual page it's difficult to say. From the most recent
"misteries" of this kind: are you using full-qualified page with
<html>, <head> and <body> : or a "lazy version" with body elements
only? (Firefox spits on the last one).
 
G

GTi

VK said:
Nasty gobblins in your computer? :)
That must be some communication problem with 'PostInformationWindow',
without an actual page it's difficult to say. From the most recent
"misteries" of this kind: are you using full-qualified page with
<html>, <head> and <body> : or a "lazy version" with body elements
only? (Firefox spits on the last one).

LOL
The whole page is rater big but it is html verified with FireFox.
I guess it is something in my code somwhere.
Topic locked.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,981
Messages
2,570,187
Members
46,731
Latest member
MarcyGipso

Latest Threads

Top