I'm experiencing a problem with the display of accented characters via AJAX and jQuery. I'll explain it in more detail.
I have a page where it has an input
field. When I fill that field with 4 characters (which must be an ICAO code for an airport), it calls a PHP script via AJAX. The script is the following:
File: ajax.airport.php
<?php
include("mysqlexec.inc.php");
include("functions.inc.php");
if(isset($_GET['icao'])){
$airportData = GetAirportInfo($_GET['icao']);
if (!empty($airportData["Name"])) {
echo $airportData["Name"];
} else {
echo "Not found!";
}
}
?>
The function GetAirportInfo();
makes a HTTP request to the Our Airports website, where the airport's name is displayed. If you can check this example page, you may note that the ICAO code is SBGL, which was entered by the user on the input
and the return of the GetAirportInfo();
function (which is the element of an array) will be Galeão - Antônio Carlos Jobim Intl, with some accented characters.
The problem is, when echoing this on the file, there appears Gale�o - Ant�nio Carlos Jobim Intl instead.
All files are UTF-8
(without BOM). I tried several functions (PHP and JS types), but that proved to be unsuccessful.
The jQuery function executed on the input is this:
function showAirport(icao, dest) {
var icao=icao.toUpperCase();
if (icao.length < 4) {
$("#"+dest).html("");
} else {
$("#"+dest).html('<img src="images/loadingsm.gif"/>');
$.ajax({
type : "GET",
url : "ajax.airport.php",
dataType: "html",
data : { icao: icao },
success : function (result) {
$("#"+dest).html(result);
},
});
}
};
Any help is welcome.