title: Jquery: ajax post and encoding
body: <p>I am unable to understand why I can't get a correct ISO-8859-1 charstet from the server answer. Being this a work on legacy code, i hardly could change charset encoding on the pages.</p>
  
  <p>I make use of the JQuery call</p>
  
  <pre><code>$.post("server-side-code", {t:ctext, i:ioff, sid:sessionid},  
      function(data, status) {            
         $('#chk').append(data); 
       });
  </code></pre>
  
  <p>posting a textarea value created using javascript:</p>
  
  <pre><code>&lt;form accept-charset='ISO-8859-1' method='post'&gt;
  &lt;textarea cols='40' rows='8' id='commento'&gt;&lt;/textarea&gt;&lt;br&gt;
  &lt;input type='button' value='invia' id='submit'&gt;&lt;/form&gt;
  </code></pre>
  
  <p>The server side script processing the request declares at its very top:</p>
  
  <pre><code>text/html; charset=ISO-8859-1
  </code></pre>
  
  <p>so, honestly, I can't figure out what else I should declare, in terms of encoding. This notwithstanding, the accented characters "àèéìòù" bounce back as: "Ã Ã¨Ã©Ã¬Ã²Ã¹" when placing the server answer in an HTML element</p>
  
  <p>The source is saved as ascii. Tryng to do this to have rudimentary Html encoding on the variable to be posted does not solve:</p>
  
  <pre><code>ctext = escapeHTML(ctext);
  
  function escapeHTML (str)
  {
     var div = document.createElement('div');
     var text = document.createTextNode(str);
     div.appendChild(text);
     return div.innerHTML;
  }; 
  </code></pre>
  
  <p>Some idea?</p>
  
  <p>Thanks!</p>