I'm using this code to load content from the DB when the user selects an option :
<script type="text/javascript" >
function setStore(value)
{
$.get("getStoreMetaInfo.php", {store_id: value, meta_type : 3},function(data){
document.getElementById("tvaddedtext").value = data.tv_lamp;
document.getElementById("parttvaddedtext").value = data.tv_part_no;
}, "json");
}
</script>
in getStoreMetaInfo.php I'm doing a select from the DB and creating associative array and doing json_encode :
$meta=mysql_fetch_array($result_meta);
$result = array("tv_lamp"=>$meta['tv_lamp'],"tv_part_no"=>$meta['tv_part_no'],
"projector_lamp"=>$meta['projector_lamp'],"projector_part_no"=>$meta['projector_part_no']);
$out = json_encode($result);
echo $out;
When the text I get from the DB is in English everything is working fine, but when I get spanish charecters for example the array $result looks like this (when using var_dump):
array(4) {
["tv_lamp"]=>
string(40) "%BRAND_PROJECTOR_MODEL% TV de la L�mpara"
["tv_part_no"]=>
string(32) "%BRAND_PARTNUM% TV de la L�mpara"
["projector_lamp"]=>
string(44) "%BRAND_PROJECTOR_MODEL% Lamparas Proyectores"
["projector_part_no"]=>
string(37) "%BRAND_PARTNUM% Lamparas Proyectores"
}
and the json object I get looks like this (in firebug response):
{"tv_lamp":null,"tv_part_no":null,"projector_lamp":"%BRAND_PROJECTOR_MODEL% Lamparas Proyectores","projector_part_no":"%BRAND_PARTNUM% Lamparas Proyectores"}
(the first two parameters are empty)
How can I make the json encoding work with those charecters?
By the way, in the page where I'm using the "setStore" function, I have:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
in the page head