jquery+ajax获取的json数值中文是乱码
<!DOCTYPEhtml><htmllang="en"><head><metahttp-equiv="content-type"content="text/html";...
<!DOCTYPE html><html lang="en"><head> <meta http-equiv="content-type" content="text/html"; charset="utf-8" /> <title>data.html</title> <script src="js/jquery-1.11.1.js" type="text/javascript" charset="utf-8"></script> <script type="text/javascript" charset="utf-8"> $(function() { $.ajax({ type:"GET", url:"data.json", dataType:"json", success:function(myjson){ var test = eval(myjson); alert(test[0].name+" "+test[0].data); }, error:function(){ alert("error"); } }); }); </script></head><body></body></html>
----------------------------------------------------------------------------------上面是html代码-------------------------
[ { "name": "一季度", "data":10 }, { "name": "二季度", "data": 7 }, { "name": "三季度", "data": 5 }, { "name": "四季度", "data":27 }]
-------------------------------------------------------------------------------------上面是json代码------------------------
结果是这样乱码 怎么才能输出中文 展开
----------------------------------------------------------------------------------上面是html代码-------------------------
[ { "name": "一季度", "data":10 }, { "name": "二季度", "data": 7 }, { "name": "三季度", "data": 5 }, { "name": "四季度", "data":27 }]
-------------------------------------------------------------------------------------上面是json代码------------------------
结果是这样乱码 怎么才能输出中文 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励10(财富值+成长值)+提问者悬赏5(财富值+成长值)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询