Lrlthink 2013-11-28 03:11 采纳率: 33.3%
浏览 5593

ajax异步查询结果的显示?

function querySubmit(){
$.ajax({
type: "get",
url: "/personinfomanage/queryDatas",
data:{"name":$("#searchName").val(),"skill":$("#searchSkill").val()},
dataType: "json",
success:function (result) {
alert("success!");
if(result!=""){
var datalist = eval ("(" + result + ")");
alert(datalist);
var cur=1;
createPages(totalpage,cur);//生成页码
var persons = data.persons;
var i;
for(i = 0;i<persons.length;i++){

         }
        }
    }
});

为什么function(result)不执行? 用firebug执行到function(result)语句就跳出了?
json设置方式:
PrintWriter out = null;
response.setContentType("application/json");
try {
out = response.getWriter();
out.write(result);
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(result);

下面是我的json字符串:System.out.println(result);的结果

[{"id":766,"description":"what the fuck?!","creationTime":"2013-11-07","firstName":"Michael","lastName":"Gyger","skills":"","birthDate":"0001-01-01","email":"counter55@yahoo.com","webSiteName":"NONE","genderTag":1,"birthYear":1,"phone":"","photo":"","interests":"","certification":""},{"id":768,"description":"CISA,CISM,CISSP,MCSE","creationTime":"2013-11-07","firstName":"Michael","lastName":"Gerleman","skills":"","birthDate":"0001-01-01","email":"michael_gerleman@yahoo.com","webSiteName":"MGerleman","genderTag":1,"birthYear":1,"phone":"","photo":"","interests":"","certification":""},{"id":769,"description":"","creationTime":"2013-11-07","firstName":"Michael","lastName":"Palamar","skills":"","birthDate":"0001-01-01","email":"map0009@aol.com","webSiteName":"MichaelPalamar","genderTag":1,"birthYear":1,"phone":"","photo":"","interests":"","certification":""},{"id":799,"description":"","creationTime":"2013-11-07","firstName":"Michael","lastName":"Roth","skills":"","birthDate":"0001-01-01","email":"MJRoth@hot.rr.com","webSiteName":"NONE","genderTag":1,"birthYear":1,"phone":"","photo":"","interests":"","certification":""},{"id":821,"description":"","creationTime":"2013-11-07","firstName":"Michael","lastName":"Story","skills":"","birthDate":"0001-01-01","email":"mutineer7@hotmail.com","webSiteName":"NONE","genderTag":1,"birthYear":1,"phone":"","photo":"","interests":"","certification":""}]

  • 写回答

1条回答 默认 最新

  • whk010 2013-11-28 05:53
    关注

    输出的格式错误,应该是一个串,不应该是多个串,修改成一个就可以了。{"id":"821"...,"id":"822"...},希望你能看懂我的写法

    评论

报告相同问题?

悬赏问题

  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题