title: submitting form with accented characters via xmlhttprequest
body: <p>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 :-/  </p>
  
  <p>Let's look at the code.  My javascript function (note the commented out line):</p>
  
  <pre><code>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);
  </code></pre>
  
  <p>This is a shortened view, check out line 1510 at <a href="http://archive.cyark.org/sitemanager/sitemanager.js" rel="nofollow">http://archive.cyark.org/sitemanager/sitemanager.js</a> to view the entire function.</p>
  
  <p>Then on the receiving php page, I have at the top:</p>
  
  <pre><code>header('Content-Type: text/html; charset=ISO-8859-1'); 
  </code></pre>
  
  <p>Followed by some basic php to build a string with the post data and submit it as an update to mysql. </p>
  
  <p>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?</p>