ajax json
加载另一个程序jsonGene.jsp生成json数据的代码是:
JScript code
function show(){
$.getJSON(
"jsonGene.jsp",
function(data){
$.each(data, function(index, values){
$.each(values, function(key, value){
$("#page").append(value + "<br>");
});
});
});
sHeight = 0;
sTop = 0;
}
总是读不出来,但是我把程序生成的json数据存在文件中,url改成文件名就能读出来。
生成的Json数据是:
[
{
"patternTypes": "PER,CIT",
"pattern1": "1177_3_14_;",
"label": "negPlace",
"value": "0.5",
"anotherPattern1": "knock.v DATE @"
},
{
"patternTypes": "PER,CIT",
"pattern1": "126_14_53_;14_53_24_;",
"label": "isInCity",
"value": "0.38888889",
"anotherPattern1": "marry.v in.p"
},
{
"patternTypes": "PER,CIT",
"pattern1": "14_53_24_;",
"label": "isInCity",
"value": "0.5",
"anotherPattern1": "marry.v in.p"
},
{
"patternTypes": "PER,CIT",
"pattern1": "14_628_24_;",
"label": "isInCity",
"value": "1.0",
"anotherPattern1": "arrive.v in.p"
},
{
"patternTypes": "PER,CIT",
"pattern1": "1505_75_42_;75_42_14_;",
"label": "negPlace",
"value": "0.3640873",
"anotherPattern1": "score.v goal.n against.p @"
},
{
"patternTypes": "PER,CIT",
"pattern1": "1505_75_42_;75_42_14_;",
"label": "negPlace",
"value": "0.3640873",
"anotherPattern1": "score.v goal.n against.p @ n.p @"
}
]
生成json数据jsonGene的代码为:
Java code
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="handle.DBlogic"%>
<%@ page import="handle.Seed"%>
<%@ page import="java.util.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title></title>
</head>
<body>
<%
DBlogic dblogic = new DBlogic();
ArrayList<Seed> seedList = dblogic.getdata();
String str = "[";
int i;
for(i=0; i<seedList.size()-1; i++){
Seed seed = seedList.ge