I am having following Jquery coding,
$.ajax({
url: "dataAdd.php",
type: "POST",
data: data,
contentType: "application/x-www-form-urlencoded; charset=UTF-8",
cache: false,
dataType: "json",
success: function(data) {
$("#result").html(data["result"]);
},
error : function(jqXHR, textStatus, errorThrown) {
alert('Error: ' + jqXHR.status);
},
});
and having the following PHP coding,
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 01 Jan 1996 00:00:00 GMT');
header('Content-type: application/json; charset=UTF-8');
session_start();
if(isset($_SESSION['username']))
{
$sess_tab = trim($_SESSION['username']);
}
$data = // Some result stuff //;
$data = array("result"=>$ress);
echo json_encode($data);
This coding perfectly sends back all data in English(text or URL). But when it comes to handle Chinese, Japanese or other foreign language wikipedia URLs, the result is:
THIS RESULT IS OBSERVED ON FIREBUG, {result: null}
But for English text with little foreign text, we get the following response properly,
{"result":"<table><tr><td align=\"center\"><div id=\"btn_mypage\"><a href=\"http:\/\/www.fran.com\" target=\"_blank\">Fran\u00e7aise Fran\u00e7ais<\/a><\/div><\/td><td align=\"center\"><div id=\"btn_mypage\"><a href=\"http:\/\/ru.wikipedia.org\/wiki\/%D0%97%D0%B0%D0%B3%D0%BB%D0%B0%D0%B2%D0%BD%D0%B0%D1%8F_%D1%81\" target=\"_blank\">Portada<\/a><\/div><\/td><td align=\"center\"><\/td><td align=\"center\"><\/td><\/tr><\/table>"}
Note: Our contentType is contentType: "application/x-www-form-urlencoded; charset=UTF-8", as Jquery doc specifies.
We have set dataType, header and UTF-8 in our code. The ajax json Request is always successful with all data but response sucks. Anybody faced similar situation and any suggestions?
If you find any mistakes in the query, freely edit it.
Does anybody have any idea about how we can modify the below coding to accept or receive all languages in ajax json response? This is found in another stackoverflow question.
<?php
header("Content-type: text/csv; charset=GB2312");
$arr = array('丂','亐');
echo json_encode($arr);
?>
This question seems to be in need of expert jquery ajax programmers. Shall we move the question status to Jquery Ajax team?