为什么点完按钮它没动静啊,一点内容它也不肯显示啊?有解析JSON的成功案例还望给我发几个参考,忘各位大侠赐教,谢谢!<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" " http://www.w3.org/TR/html4/strict.dtd ">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Json Document</title>
<script type="text/javascript" src="jquery-1.6.2.js"></script>
<script type="text/javascript">
$(function(){
$("#button1").click(function(){
$.getJSON('b.json',function(data){
$("#json").empty();
$.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 >"+entry[ definition ];
if(entry[ quote ]){
html+="<div class= quote >";
$.each(entry[ quote ],function(quoteIndex,line){
html+="<p>"+line+"</p>";
});
html+="</div>";
}
html+="</div>";
html +="</div>";
$("#json").after(html);
});
});
});
});
</script>
</head>
<body>
<button id="button1"><b>Get Json Document</b></button>
<div id="json" >hghghghg</div>
</body>
</html>以下是b.json文件内容:
[
{
"term":"BACCHUS",
"part":"n.",
"definition":"A convenient deity invented by the ancients as an excuse for getting drunk.",
"quote":[
"Is public worship,then,a sin.",
"That for devotions paid to Bacchus",
"The lictors dare to run us in.",
"And resolutely thump and whack us?"
],
"author":"Jorace"
},
{
"term":"BACKBITE",
"part":"v.t.",
"definition":"To speak of a man as you find him when he can t find you."
},
{
"term":"BEARD",
"part":"n.",
"definition":"The hair that is commonly cut off by those who justly execrate the absurd Chinese custom of shaving the bead."
}
]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Json Document</title>
<script type="text/javascript" src="jquery-1.6.2.js"></script>
<script type="text/javascript">
$(function(){
$("#button1").click(function(){
$.getJSON('b.json',function(data){
$("#json").empty();
$.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 >"+entry[ definition ];
if(entry[ quote ]){
html+="<div class= quote >";
$.each(entry[ quote ],function(quoteIndex,line){
html+="<p>"+line+"</p>";
});
html+="</div>";
}
html+="</div>";
html +="</div>";
$("#json").after(html);
});
});
});
});
</script>
</head>
<body>
<button id="button1"><b>Get Json Document</b></button>
<div id="json" >hghghghg</div>
</body>
</html>以下是b.json文件内容:
[
{
"term":"BACCHUS",
"part":"n.",
"definition":"A convenient deity invented by the ancients as an excuse for getting drunk.",
"quote":[
"Is public worship,then,a sin.",
"That for devotions paid to Bacchus",
"The lictors dare to run us in.",
"And resolutely thump and whack us?"
],
"author":"Jorace"
},
{
"term":"BACKBITE",
"part":"v.t.",
"definition":"To speak of a man as you find him when he can t find you."
},
{
"term":"BEARD",
"part":"n.",
"definition":"The hair that is commonly cut off by those who justly execrate the absurd Chinese custom of shaving the bead."
}
]
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货