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 8276273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:19:27+00:00 2026-06-08T08:19:27+00:00

I implemented this form submission method that uses xmlhttpreqeust. I saw the new html5

  • 0

I implemented this form submission method that uses xmlhttpreqeust. I saw the new html5 feature, FormData, that allows submission of files along with forms. Cool! However, there’s a problem with accented characters, specifically those stupid smart quotes that Word makes (yes, I’m a little bias against those characters). I used to have it submit to a hidden iframe, the old school way, and I never had a problem with the variety of weird characters that was put in there. But I thought this would be better. It’s turning out to be a bigger headache :-/

Let’s look at the code. My javascript function (note the commented out line):

var xhr = new XMLHttpRequest();
var fd = new FormData(form);

xhr.addEventListener("error", uploadFailed, false);
xhr.addEventListener("abort", uploadCanceled, false);
xhr.addEventListener("load", uploadComplete, false); 

xhr.open($(form).attr('method'), $(form).attr('action'));

//xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=ISO-8859-1");
xhr.send(fd);

This is a shortened view, check out line 1510 at http://archive.cyark.org/sitemanager/sitemanager.js to view the entire function.

Then on the receiving php page, I have at the top:

header('Content-Type: text/html; charset=ISO-8859-1'); 

Followed by some basic php to build a string with the post data and submit it as an update to mysql.

So what do I do? If I uncomment the content-type setting in javascript it totally breaks the POST data in my php script. I don’t know if the problem is in javascript, php or mysql. Any thoughts?

  • 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-08T08:19:28+00:00Added an answer on June 8, 2026 at 8:19 am

    Encoding problems are sometimes hard to debug. In short the best solution is to literally use UTF8 as encoding everywhere. That is, every component of your application stack.

    Your page seems to be delivered as ISO-LATIN-1 (sent via HTTP header from your webserver) which leads browsers to use latin1 or some Windows equivalent like windows-1252 even though you may have META elements in your HTML’s HEAD telling user agents to use UTF8. The HTTP header takes precedence. Check the delivery of your other file formats (especially .js) to be UTF8 as well. If your problems are still appearing after configuring everything client side related (HTML, JS, XHR etc.) to use UTF8 you will have to start checking your server side for problems.

    This may include such simple problems as PHP files not being proper UTF8 (very unlikely on linux servers I’d say) but usually consists of problems with mysql configurations (server and client), database and table default encoding (and collation) and the correct connection settings. Problems may also be caused by incorrect PHP ini or mbstring configuration settings.

    Examples (not complete; using mysql here as a common database example):

    MySQL configuration

    [mysqld]
    default_character_set = utf8
    character_set_client = utf8
    character_set_server  = utf8
    [client]
    default_character_set = utf8
    

    Please note, that those settings are different for mysql version 5.1 and 5.5 and may prevent the mysqld from starting when using the wrong variable. See http://dev.mysql.com/doc/refman//5.5/en/server-system-variables.html and http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html for details.

    You may check your mysql variables via CLI:

    mysql> SHOW VARIABLES LIKE '%char%';
    Variable_name Value
    character_set_client utf8
    character_set_connection utf8
    character_set_database utf8
    character_set_filesystem binary
    character_set_results utf8
    character_set_server utf8
    character_set_system utf8
    

    When creating databases and tables try to use something like

    CREATE DATABASE $db /*!40100 DEFAULT CHARACTER SET utf8 */
    

    PHP.ini settings (should be the default already):

    default_charset = "utf-8"
    

    MB-String extension of PHP uses latin1 by default and should be reconfigured if used:

    [mbstring]
    mbstring.internal_encoding = UTF-8
    mbstring.http_output = UTF-8
    ...some more perhaps...
    

    Webserver settings (Apache used as example, applies to other servers as well):

    # httpd.conf
    AddDefaultCharset UTF-8
    

    PHP source codes may use header settings like:

    header('Content-type: text/html; charset=UTF-8');
    

    Shell (bash) settings:

    # ~/.profile
    export LC_CTYPE=en_US.UTF-8
    export LANG=en_US.UF-8
    

    The above list is presented here just to give you a hint on what pitfalls may wait for you in certain situations. Every single component of your used web stack must be able to use UTF8 and should be configured correctly to do so. Nonetheless usually a simple correct HTTP header of UTF8 is enough to sort most problems out though. Good luck! 🙂

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

Sidebar

Related Questions

I implemented this Jquery show/hide code and everything works fine except that the box
I've implemented this method to return the section header height. However, when the height
So, I have implemented this method to add a footer to my table view:
I have a form (form2) and I implemented the following PUBLIC method: function ShowInterface(i:integer):boolean;
I've implemented CAPTCHA for a form submission page in my app as per code
I currently have an enquiry submission form that can only be completed by registered
I have a table-form which I implemented this way: <tr> <td>Start Date:</td> <td>{{ form_widget(form.start_date)
I have a form that accepts numeric input from the user. Upon form submission,
I've implemented this C# client which communicate with asynchronous connection to another server I've
I've implemented this search algorithm for an ordered array of integers. It works fine

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.