function result-ajax异步查询结果的显示?

问题描述

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":""}]

解决方案

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

时间: 2025-01-21 15:08:16

function result-ajax异步查询结果的显示?的相关文章

使用Jquery+Ajax+Json如何实现分页显示附JAVA+JQuery实现异步分页_AJAX相关

先给大家展示下运行效果图:  1.后台action产生json数据. List blackList = blackService.getBlackInfoList(mobileNum, gatewayid, startDate, endDate); int totalRows = blackList.size(); StringBuffer sb = new StringBuffer(); sb.append("{\"totalCount\":\""+to

使用Jquery+Ajax+Json如何实现分页显示附JAVA+JQuery实现异步分页

先给大家展示下运行效果图: 1.后台action产生json数据. List blackList = blackService.getBlackInfoList(mobileNum, gatewayid, startDate, endDate); int totalRows = blackList.size(); StringBuffer sb = new StringBuffer(); sb.append("{\"totalCount\":\""+tot

jQuery Ajax 异步加载显示等待效果代码分享_jquery

AJAX 全称 Asynchronous JavaScript and XML(异步的 JavaScript 和 XML).它并非一种新的技术,而是以下几种原有技术的结合体. 1) 使用CSS和XHTML来表示. 2) 使用DOM模型来交互和动态显示. 3) 使用XMLHttpRequest来和服务器进行异步通信. 4) 使用javascript来绑定和调用. 通过AJAX异步技术,可以在客户端脚本与web服务器交互数据的过程中使用XMLHttpRequest对象来完成HTTP请求(Reques

ajax的异步请求-ajax 前台传数据后台显示出问题

问题描述 ajax 前台传数据后台显示出问题 前台数据为UName=*&UPWd=*&UCode=* 后台data只有UName=*.不知道问题出在哪求助.下面是代码. <script src="../../JS/msgBox.js" type="text/javascript"></script> <script type="text/javascript"> var msgBox = nul

MVC+jQuery.Ajax异步实现增删改查和分页_jquery

本文实例为大家分享了MVC+jQuery.Ajax异步实现增删改查和分页的具体代码,供大家参考,具体内容如下 1.Model层代码 using System; using System.Data; using System.Configuration; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; usin

jQuery+Ajax+PHP+Mysql实现分页显示数据实例讲解_jquery

本文使用jQuery,结合PHP和Mysql,通过实例讲解如何实现Ajax数据加载效果. HTML <div id="list"> <ul></ul> </div> <div id="pagecount"></div> 页面中,#list用来展示数据列表,包括本例要展示的商品图片和标题,#pagecount用来展示分页条,即本例中的上一页.下一页. 当然,别忘了,在head中预先载入jquery

jsp页面 列表 展示 ajax异步实现方法_JSP编程

1. 服务端先返回页面基本结构(如message.jsp), <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ tag

使用Ajax异步上传图片的方法(html,javascript,php)

前两天项目中需要用到异步上传图片和显示上传进度的功能,于是找了很多外国的文章,翻山越岭地去遇上各种坑,这里写篇文章记录一下. HTML HTML代码没什么好说,一个form表单,还有文件类型的input.我们来看js部分. javascript //绑定了`submit`事件. $('#fileupload-form').on('submit',(function(e) { e.preventDefault(); //序列化表单 var serializeData = $(this).seria

Ajax在请求过程中显示进度的简单实现_AJAX相关

Ajax在Web应用中使用得越来越频繁.在进行Ajax调用过程中一般都具有这样的做法:显示一个GIF图片动画表明后台正在工作,同时阻止用户操作本页面(比如Ajax请求通过某个按钮触发,用户不能频繁点击该按钮产生多个并发Ajax请求):调用完成后,图片消失,当前页面运行重新编辑.以下图为例,页面中通过一个Load链接以Ajax请求的方式加载数据(左).当用户点击该链接之后,Ajax请求开始,GIF图片显示"Loading"状态,同时当前页面被"罩住"防止用户继续点击L