views:

622

answers:

2

I've an issue with the same piece of code running fine on my live website but not on my local development server.

I've an Ajax function that updates a div. The following code works on the live site:

self.xmlHttpReq.open("POST", PageURL, true);
self.xmlHttpReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
self.xmlHttpReq.setRequestHeader("Content-length", QueryString.length);
//..update div stuff...
self.xmlHttpReq.send(QueryString);

When I try to run this on my local machine, nothing is passed to the QueryString.

However, to confuse matters, the following code does work locally:

self.xmlHttpReq.open("POST", PageURL+"?"+QueryString, true);
self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
//..div update stuff..
self.xmlHttpReq.send(QueryString);

But, I can't use the code that works on my local machine as it doesn't work on the live server (they've changed their policy on querystrings for security reasons)!

I can alert the Querystring out so I know it's passed into the function on my local machine. The only thing I can think of is that it's a hardware/update issue.

Live Site is running IIS 6 (on a WIN 2003 box I think) Local Site is running IIS 5.1 (On XP Pro)

Are there some updates or something I'm missing or something?

Thanks in advance

KT

+1  A: 

Is there a reason you're explicitly setting the Content-Length header in the first example? You... shouldn't need to do this, and i wouldn't be surprised to find it causing problems.

Oh, and check your encoding routine. The rules are not quite the same for querystrings and POSTed form data.

Shog9
A: 

I would guess that Shog9 is right, and that IIS 6 i smart enough to ignore your request and send the correct headers, while 5.2 throws an error.

UltimateBrent