【发布时间】:2017-02-09 15:41:59
【问题描述】:
在我的数据库中,我有外国名字的特殊字符。我在 html 中正常输入该特殊字符时使用了<meta charset="utf-8">,它工作正常。但是,当我调用 ajax 请求并使用 html(data) 将该特殊字符显示到特定 div 中时,文本将更改为 ????? ??????? ????? 如何解决此问题
html
<div id="country_info"> </div>
js
$(document).on('change','#country_list', function(){
var thisVal_id = $(this).val();
$.ajax({
url:'../ajax/paraphernalia/ajax_displayCountry_info.php',
type:'post',
data: {thisVal_id : thisVal_id , event_id : event_id},
cache : false,
success : function(data){
$('#country_info').html(data);
}
});
});
response.php
//this select option contains different foreign characters
$output .= '<select id="official_name" class="form-control" style="padding:0px; !important">';
while($row1 = mysql_fetch_assoc($sql1)){
$output .= '<option value="'.$row1['name_official'].'">'.$row1['name_official'].'</option>';
}
$output .= '</select>';
echo $output;
【问题讨论】:
-
你可能想看看这个 stackoverflow answer。希望有帮助!!
-
谢谢你,但我使用
mysql_set_charset("UTF8");将我的页面的每个顶部都放在了解决我的问题
标签: javascript php jquery html ajax