$('#letter-b a').click(function(){ $.getJSON('__PUBLIC__/b.json',function(data){ $.each(data,function(entryIndex,entry){ var html = '<div class="entry">'; html += '<h3 class="term">' + entry['term'] + '</h3>'; html += '<div class="part">' + entry['part'] + '</div>'; html += '<div class="definition">'; html += entry['definition']; html += '</div>'; html += '</diiv>'; $('#dictionary').append(html); }); }); return false; });写了一个ajax的函数,结果在Chrome和IE中什么反应也没有,
[{ "term": "BACCHUS","part": "n.","definition": "A convenient deity invented by the...","quote": [ "Is public worship,then,a sin,","That for devotions paid to Bacchus","The lictors dare to run us in,"And resolutely thump and whach us?" ],"author": "Jorace" },{ "term": "BACKBITE","part": "v.t.","definition": "To speak of a man as you find him when..." },{ "term": "BEARD","definition": "The hair that is commonly cut off by ..." }]
检查了一下,文件中开始和结尾的括号[]没有加上去。加上去之后,chrome下可以正常显示,在IE下还是没有反应。然后再调用的PHP文件中定义了字符编码格式,IE下正常。
header ( 'Content-Type: text/javascript; charset=UTF-8' ); $this->display();(lnmp环境+thinkPHP) 原文链接:https://www.f2er.com/json/290521.html