PDA

View Full Version : POST does not work in Firefox but works in chrome



htmlster
03-03-2011, 05:28 PM
Hi,

I'm making a ajax call as

xmlhttp.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded");

xmlhttp.open ("POST", url);

xmlhttp.send (parameters);

url, parameters are already declared.

When this code is executed. post works fine (parameters are being set in application) in chrome, but not in firefox.


When i looked through the contents through sniffer (wireshark).

I found out that
in Firefox:
Content-Type: application/x-www-form-urlencoded; char-set: UTF-8

Where as in chrome:
Content-Type: application/x-www-form-urlencoded

does char-set affects post call?. If yes, how can i call request header to not to set "char-set"


Can any one please let me know how i can proceed with this.

hdewantara
03-04-2011, 10:25 AM
I would try to post form through regular form using firefox first;
then if it is successful, moved it to ajax method.

Is yours uploading files too?

venegal
03-04-2011, 03:10 PM
Please elaborate on what "post does not work" exactly means, and provide a link to a live example, so we can see the server response.

htmlster
03-10-2011, 06:02 AM
Sorry for the confusion.

When i make call as below from javascript:

xmlhttp.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded");

xmlhttp.open ("POST", url);

xmlhttp.send (parameters);

And observed in sniffer (wireshark):

I found out that when the html file which calls the above javascript is opened
in Firefox:
Content-Type is observed as:
Content-Type: application/x-www-form-urlencoded; charset: UTF-8

Where as in chrome:
Content-Type is observed as:
Content-Type: application/x-www-form-urlencoded

I want to avoid, 'charset: UTF-8" string set for Content-Type.

Is there any way with setRequestHeader function so that charset:UTF-8 can be removed for Content-Type?.

The webserver which i have can only understand "Content-Type: application/x-www-form-urlencoded"

I dont have any live link to demonstrate this.


Let me know if any thing is not clear.

Please help me out in resolving this.

devnull69
03-10-2011, 06:40 AM
So what is the actual charset you want to use here? If it is ISO-8859-1 you can write this:


xmlhttp.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded; charset: ISO-8859-1");

Don't be misled by the Chrome Content-type. Even if no charset is specified there is still one charset being used. You will have to find out which one ...