jqgrid readyState = 4,responseText是对的,status = 200,statusText = ok!但它不起作用

时间:2014-06-19 06:27:59

标签: jqgrid

<%@ page contentType="text/html;charset=utf-8" %>
<%@ page import = "org.json.*" %>
<%@ page import="java.lang.*, java.lang.Math, java.util.Date, com.DBConnectionManager.*,java.sql.*, java.util.*, java.util.Enumeration, java.util.regex.* , javax.mail.*, javax.mail.internet.*" contentType="text/html;charset=utf-8" %>
<%@ include file= "../DBheader.jsp" %>// for DB connection

<%

    response.setHeader("content-Type","application/json;charset=utf-8");

    String sql_jqgrid="SELECT g.org_id,g.title,g.date_reg,g.em_name, g.view_count,s.filename, g.download_count FROM org g,orgpds s WHERE g.org_id=s.org_id(+)";

        ps = conn.prepareStatement(sql_jqgrid);
        rs = ps.executeQuery();

        JSONArray jsonArray = new JSONArray();

        int totalpages=0;
        int totalrecords=0;
        int currpage=0;
        double limt=10; 

        while(rs.next()){
            JSONObject object = new JSONObject();

            object.put("org_id",rs.getString("org_id"));
            object.put("title",rs.getString("title"));
            object.put("date_reg",rs.getString("date_reg"));
            object.put("em_name",rs.getString("em_name"));
            object.put("view_count",rs.getString("view_count"));
            object.put("filename",rs.getString("filename"));
            object.put("download_count",rs.getString("download_count"));

            jsonArray.put(object);
            totalrecords++;
        }

        totalpages= (int)Math.ceil(totalrecords/limt);

        JSONObject jsonObject = new JSONObject();

        jsonObject.put("totalpages",totalpages);
        jsonObject.put("currpage",1);
        jsonObject.put("totalrecords",totalrecords);
        jsonObject.put("invdata",jsonArray);

        out.clear();
        out.println(jsonObject); 
        out.flush();
%>

<%@ include file= "../DBfotter.jsp" %>// for DB connection

我得到了这个值

  

{&#34; currpage&#34;:1,&#34;总记录&#34;:45,&#34;总页数&#34;:5,&#34; invdata&#34;:[{&# 34; org_id&#34;:&#34; 4&#34;&#34;标题&#34;:&#34; dfdfdfdff&#34;&#34; date_reg&#34;:&#34; 2009-10 -05   00:00:00.0&#34;&#34; DOWNLOAD_COUNT&#34;:&#34; 0&#34;&#34; VIEW_COUNT&#34;:&#34; 9&#34;},{&# 34; org_id&#34;:&#34; 5&#34;&#34;标题&#34;:&#34; AAA&#34;&#34;文件名&#34;:&#34; aa1.zip& #34;&#34; date_reg&#34;:&#34; 2010-09-29   00:00:00.0&#34;&#34; DOWNLOAD_COUNT&#34;:&#34; 2&#34;&#34; VIEW_COUNT&#34;:&#34; 26&#34;&#34; em_name&#34;:&#34;管理&#34;}]}

它的jqGrid来源

$("#list").jqGrid({
            url:'../includes/jqgrid/org_list_json.jsp',
            type : "POST",
            datatype:'json',
            jsonReader: {
                root:"invdata",
                page:"currpage",
                total:"totalpages",
                records:"totalrecords",
                cell:"",
                repeatitems : true //search elements in the json data by name 
                },
            loadError:function(xhr,status,error){alert(xhr.state);},
            loadComplete:function(data){alert(data);}, 
            gridComplete:function(data){alert("complete");}, 
            colNames: ['number','contact','date','person','count','download','download_count'],
            colModel: [

                       {name: 'org_id', index: 'org_id',align: 'center', frozen : true, sorttype: 'number', hidden:true},   
                       {name: 'title', index: 'title',align: 'center', sorttype: 'number'},
                       {name: 'date_reg', index: 'date_reg', align: 'left', sorttype: 'date',formatter: 'date', formatoptions: {srcformat:"Y-m-d",newformat:"Y-m-d"}},
                       {name: 'em_name', index: 'em_name', align: 'center'},
                       {name: 'view_count', index: 'view_count', align: 'center'},
                       {name: 'filename', index: 'filename', align: 'left'},
                       {name: 'download_count', index: 'download_count', sorttype: 'number', resizable: true, align: 'center'},
                       ],    

                       rowNum: 10,/
                       rowList: [5, 10, 20, 50],
                       autowidth:true, 
                       width: function(){$("#list").setGridWidth($(this).width(), true);}, 
                       height: '100%',
                       pager: '#pager',
                       gridview: true,
                       rownumbers: false,  
                       sortable: true,
                       rownumbers: true,
                       //multiselect: true, 
                       sortname: 'date_reg',
                       gridview: true,

                       viewrecords: true,
                       scrollOffset: 0,
                       sortorder: 'desc'          


                       });  

readyState = 4,responseText为right,status = 200,statusText = ok!但是我得到了一个错误信息&#34; syntaxError意外的令牌&#34; &LT; (在铬中)

1 个答案:

答案 0 :(得分:0)

我已经解决了自己的问题。

我只需添加&#34; out.close(); &#34; org_list_json.jsp的底部 。 之后jqGrid运作良好。

但我不知道为什么。

如果有人知道,你能告诉我吗?