$('#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)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。