news类的属性:
- Java code
private int id; private String content; private String title; private String p_time; private String author; private String c_id; private String imgurl; private String hot;
我从数据库中查询出这些属性,转化成json数据,通过ajax请求到这些数据然后填充到页面。具体过程如下:
action
- Java code
@JSON(name="news") public JSONArray getJSON() throws JSONException { return newsservices.showNews(this.getC_id()); } public void setJSON(JSONArray jSON) { this.JSON = jSON; }
在页面我是这样调用的,
- JScript code
$.ajax({ url: "showNewsByCidAction.do?count=7&c_id=xinwen", type:'get', //type:'jsonp', async: false, success: function(msg){ for(var i=0;i<msg.toString().length;i++){ $("#newscenter").append("<li><a href="+"newscon.html?id=" //+msg.news[i].id +msg.news[i].id +"><span class='dates'>" +msg.news[i].date.toString() +"</span><div class='ellipsis'>" +msg.news[i].title +"</div></a></li>" ); } } });
虽然能得到数据,可是一直提示id未定义(chrome浏览器)
我知道id是news的一个属性,可是该怎么做呢?
------解决方案--------------------
返回的msg具体内容是什么?
------解决方案--------------------
后台代码