...

View Full Version : Resolved how to retrieve chinese,japan, rusia,arabic character using jquery from database?



ankifreeze
03-02-2011, 06:31 AM
hello....first I can retrieve chinese,rusia,arabic from database without jquery or ajax.... but when I retrieve chinese,rusia,arabic from database using jquery or ajax it couldn't



function getdata(str)
{
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","data.php?a="+str,true);
xmlhttp.send();
}







<script type="text/javascript">
$(document).ready(function() {


$('#Form').submit(function() {
$.ajax({
type: 'GET',
url: $(this).attr('action'),
data: $(this).serialize(),
success: function(data) {
$('#data').html(data);
}
})
return false;
})
})


</script>


...... I have used accept-charset="UTF-8" in form and meta content="text/html;charset=utf-8" but still failed....

devnull69
03-02-2011, 09:09 AM
You should tell $.ajax the contentType of the received data


$.ajax({
...,
contentType: 'application/x-www-form-urlencoded;charset=UTF-8',
...
});

And you should output the characters from the script/page of the "action" attribute using something like this (PHP example):


<?php header('Content-Type: text/html; charset=UTF-8'); ?>

ankifreeze
03-02-2011, 02:40 PM
You should tell $.ajax the contentType of the received data


$.ajax({
...,
contentType: 'application/x-www-form-urlencoded;charset=UTF-8',
...
});

And you should output the characters from the script/page of the "action" attribute using something like this (PHP example):


<?php header('Content-Type: text/html; charset=UTF-8'); ?>

hello...I have resolved my problem....I put charset="utf-8" in
<script type="text/javascript" src="jquery-1.3.2.min.js" charset="utf-8"></script>

and I set configuration on mysql default-character-set=utf8
character-set-server = utf8
collation-server = utf8_general_ci

thanks for help me....:)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum