473,513 Members | 2,406 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Ajax bizare

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

Sep 29 '06 #1
9 3662

GTi wrote:
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.

Sep 29 '06 #2

Tom Cole wrote:
GTi wrote:
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.
Pragma: no-cache

This will tell the UA to always get a new response, not use one from
cache.
Sep 29 '06 #3
VK

Tom Cole wrote:
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).

Sep 29 '06 #4
GTi
VK wrote:
Tom Cole wrote:
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).
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

Sep 29 '06 #5
VK
Cache-Control: no-cache
Pragma: 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.

Sep 30 '06 #6
GTi
VK wrote:
Cache-Control: no-cache
Pragma: 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.
Thanks VK, I will try searching for it at mozilla.org.
However I got the same problem with IE !

Sep 30 '06 #7
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').i nnerHTML =
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 ?

GTi wrote:
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
Sep 30 '06 #8
VK

GTi wrote:
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>, <headand <body: or a "lazy version" with body elements
only? (Firefox spits on the last one).

Sep 30 '06 #9
GTi
VK wrote:
GTi wrote:
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>, <headand <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.

Sep 30 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
2319
by: Yarco | last post by:
I want to use "Ajax" to create my web for hobby. But i don't know whether "Ajax" is mature... And what about with php? Someone have experience on it? ....
4
4291
by: bobzimuta | last post by:
I'm creating a simple AJAX library. It's an object that will return an array containing the response text or xml. I'm trying to find a way to assign the response as a property of the object, but...
0
1826
by: melledge | last post by:
Ajax Developers' Day added to XTech 2006 agenda XTech 2006 - 17-19 May - Hotel Grand Krasnopolsky - Amsterdam, The Netherlands
0
1809
by: melledge | last post by:
Ajax Developers' Day to Kick Off XTech 2006 Conference Industry experts offer insight into next generation of the Web ALEXANDRIA, VIRGINIA, USA - April 25, 2006 - In response to the rapidly...
2
1169
by: Curt | last post by:
Thank God for backups. This is the 3rd time this kind of crap pops up. I have not been in the module these errors reference in a month. But now my app will not build because of this crap. Any...
1
16474
by: www.web20developers.com | last post by:
http://www.web20developers.com http://www.web20developers.com/index.php?option=com_content&task=view... Ajallerix : AJAX, simple, fast Web image gallery demo ; at Novell AJAX -...
10
3013
by: =?Utf-8?B?WWFua2VlIEltcGVyaWFsaXN0IERvZw==?= | last post by:
controlsPlease could some of you here post some of your live examples of AJAX (esp drag panels, collapsable panels, and popup menu.) (It's one thing to talk about how great something is, but it's...
2
2246
by: soni2926 | last post by:
hi, does anyone know of any good books on ajax and asp.net, one that teaches ajax itself before jumping in atlas? I wanted to get an understanding of ajax and how to use it, most books i've seen...
1
3390
by: shaunwo | last post by:
I'm an AJAX / DOM Novice (at best) and trying to figure out how to write the value to a couple input fields. I don't remember exactly where I got the ajax.js file I'm using from (went to the website...
0
7264
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7543
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7106
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7534
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5094
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3236
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3226
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1601
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
805
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.