json html显示中文乱码,后台请求json文件,中文出现乱码
為什么我的中文出現(xiàn)亂碼,怎么設(shè)置啊?
前臺代碼:
$(document).ready(function(){
$('a').click(function(){
$.ajax({
type: "GET",
url: "page"+$(this).text()+".json",
headers: {
//contentType : "application/json",
// "Content-Encoding": "UTF-8"
},
dataType: "json",
success: function (data) {
$('#ul').html('');
for(i=0;i var pageResult = "商品編號:"+data[i].GoodId+"商品名稱:"+data[i].GoodName+"商品價格:"+data[i].GoodPrice;
$("").html(pageResult).appendTo($('#ul'));
}
}
});
}
);
});
后臺代碼只是一個json文件
[
{
"GoodId": "100",
"GoodName": "堅(jiān)果手機(jī)",
"GoodPrice": "1999"
},
{
"GoodId": "101",
"GoodName": "IPhone",
"GoodPrice": "5000"
},
{
"GoodId": "102",
"GoodName": "華為",
"GoodPrice": "1000"
}
]
《新程序員》:云原生和全面數(shù)字化實(shí)踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀總結(jié)
以上是生活随笔為你收集整理的json html显示中文乱码,后台请求json文件,中文出现乱码的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: html圆角兼容jq,IE兼容css3圆
- 下一篇: html5 滤色,深入理解CSS mix