Letter accent and charset

Hi,

I have a html document with charset iso-8859-1. In the document I have an “à” (with accent). Why if I make an ajax request, the “à” on server side returns on the client as a “question mark” symbol? And also if I use “get” method retrieving the value of the submit that “à” disappears?
As you can see I have tried also with “è”.

here’s the code:

html code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
   <head>
   <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
   <link rel="shortcut icon" href="include/favicon.ico">
   <link rel="stylesheet" href="include/layout.css" type="text/css">
   <script type="text/javascript" src="ajax_script.js"></script>
   <title></title>
   </head>
   <body>

      <form action='javascript:send_request()' method='get'>
      <input type='submit' id='cmd_submit' name='cmd_submit' value='OK'>
      </form>
      <div id='box'>
         <p id='load_box'></p>
         à
      </div>
   </body>
</html>

javascript code:

var http = createObject();

function createObject() {
   var request_type;
   var browser = navigator.appName;
   if(browser == "Microsoft Internet Explorer") {
      request_type = new ActiveXObject("Microsoft.XMLHTTP");
   } else {
      request_type = new XMLHttpRequest();
   }
   return request_type;
}

function send_request() {
   document.getElementById('load_box').innerHTML = "Loading...";
   var cmd_submit = encodeURI(document.getElementById('cmd_submit').value);
   nocache = Math.random();
   http.open('get', 'server_script.php?cmd_submit=' + cmd_submit
                                     + '&nocache='  + nocache);
   http.onreadystatechange = show_response;
   http.send(null);
}

function show_response() {
   if(http.readyState == 4){
      var response = http.responseText;
      document.getElementById('box').innerHTML = response;
   }
}

server side in php:

<?php
   echo "<p>server response without using \\$_GET within an if construct: a, è, à</p>";

   if ( (isset($_GET['cmd_submit'])) && ($_GET['cmd_submit'] == 'OK') ) {
      echo "server response: a, è, à";
   }
?>

note: i am using ff 3.6.

please can you help me?
many thanks really!

I think that this may be related to the content-encoding that PHP uses, and not to anything of a javascript nature.

To see what type the PHP page is using, load the PHP page in Firefox, right-click on the page and choose View Info.

ok, I have inserted in the php script this:

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

and the page has been displayed correctly.
many thanks!