Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8815807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:28:06+00:00 2026-06-14T04:28:06+00:00

Recently I’ve come across some very strange behavior related to character encoding for AJAX

  • 0

Recently I’ve come across some very strange behavior related to character encoding for AJAX calls made using the POST method.
To make a long story short, I have an HTML form with text fields that can accept diacritics (e.g. “ä“). When the form is submitted, the form data is wrapped in an XML block and sent to a server, which stores that information in a MySQL database. Subsequently, that information is retrieved from the database and displayed to regular users, as is.

If the request is sent from Chrome or IE, everything is fine. This means that the data, including the diacritics, is sent, stored, then retrieved and displayed correctly. However, when I use Firefox for this, the XML appears to submit the form data right, but when I reload the web page, the previously sent diacritics don’t appear. In other words, they seem to get lost somewhere along the way.
For example, if the XML contains the word “tästä“, when I load the page I see “tst“.

Why is this happening? Is Firefox encoding the post messages differently from IE and Chrome?

In case it helps, I’ve attached the request and response headers from Chrome and Firefox, for exactly the same form content – only one example:

By the way, I’m not encoding the data before sending it to the server, just simply retrieving the value of the form fields, as is.

CHROME:

The XML data block:

<request>
<session>{hidden by me}</session>
<builder>Hem i Stan tästä</builder>
</request>

The request headers:

Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:562
Content-Type:application/x-www-form-urlencoded
Cookie:PHPSESSID=rlne2d787j0np52ec5rtn04dm1
Host:83.150.87.220
Origin:http://hidden.by.me
Referer:http://http://hidden.by.me/?c=2094211
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1
X-Requested-With:XMLHttpRequest

The response headers:

Connection:Keep-Alive
Content-Encoding:gzip
Content-Type:application/xml
Date:Mon, 17 Sep 2012 16:21:58 GMT
Keep-Alive:timeout=5, max=100
Server:Apache/2.2.11 (Win32) PHP/5.2.9-1
Transfer-Encoding:chunked
Vary:Accept-Encoding

FIREFOX:

The XML data block:

<request>
<session>{hidden by me}</session>
<builder>Hem i Stan tästä</builder>
</request>

The request headers:

Accept  */*
Accept-Encoding gzip, deflate
Accept-Language en-us,en;q=0.5
Connection  keep-alive
Content-Length  562
Content-Type    application/x-www-form-urlencoded; charset=UTF-8
Cookie  PHPSESSID=kvfg4fp2trorllim19dmn241c7
Host    hidden.by.me
Referer http://hidden.by.me/?c=2094211
User-Agent  Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20100101 Firefox/14.0.1
X-Requested-With    XMLHttpRequest

The response headers:

Connection  Keep-Alive
Content-Encoding    gzip
Content-Type    application/xml
Date    Mon, 17 Sep 2012 16:21:23 GMT
Keep-Alive  timeout=5, max=100
Server  Apache/2.2.11 (Win32) PHP/5.2.9-1
Transfer-Encoding   chunked
Vary    Accept-Encoding
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T04:28:07+00:00Added an answer on June 14, 2026 at 4:28 am

    As @Pointy mentioned some time ago, the problem was related to the Content-Type of the POST request, because Firefox appears to encode POST messages differently than other browsers.
    In my head, Data-Type and Content-Type were the same and so, I didn’t realize it’s necessary to specify UTF-8 as the character encoding standard in both cases. But once I had changed both the Content-Type and the Data-Type as well to a clear “text/xml; charset=UTF-8”, the problem was resolved.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Recently, we discovered odd behavior in some old code. This code has worked for
Recently downloaded some code for a minor open-source project related to a small webgame
Recently I'm doing some work on RTMP streaming, that is using Flowplayer to integrate
recently, while working on a db2 -> oracle migration project, we came across this
Recently, I was asked to compile some of my Android projects, based on the
Recently, I'm trying to solve all the exercises in CLRS. but there are some
Recently our WPF/Entity Framework 4.0 application has become unstable after we began using backgroundworkers
Recently, when I tried to show the results of my work (some Flex app)
Recently I faced a issue when using len() in a query to find out
Recently I installed a Visual Studio 2008 extension called VS.Php, made by Jcx Software:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.