日期:2014-05-17  浏览次数:20905 次

jquery $ajax的使用
action:
String hql="from Dictwaretype where parentcode!='0' ";
dictwaretype=this.dictwaretypeBiz.getListByHqlOther(hql, null, null, 0, 1);
JsonConfig cfg = new JsonConfig();
cfg.setJsonPropertyFilter(new PropertyFilter()
{
public boolean apply(Object source, String name, Object value) {
if(name.equals("wares")) {
return true;
} else {
return false;
}
}
});
json=JSONArray.fromObject(dictwaretype, cfg);
System.out.println(json);
打印出来:[{"msreplTranVersion":"","parentcode":"001","remark":"","waretypecode":"001001","waretypename":"利乐包"},{"msreplTranVersion":"","parentcode":"001","remark":"","waretypecode":"001002","waretypename":"利乐枕"},{"msreplTranVersion":"","parentcode":"001","remark":"","waretypecode":"001003","waretypename":"百利包"},{"msreplTranVersion":"","parentcode":"001","remark":"","waretypecode":"001004","waretypename":"塑瓶"}]

页面:
$(document).ready(function (){
$.ajax({
url:"wpgl_execute.action",
type:"post",
dataType:"json",
error:function(){
alert("服务器没有返回数据");
},
success:function(json){
alert(json);
}
});
});
为什么alert的是“服务器没有返回数据”,success:function(json){alert(json);}部分应该怎么写,请教各位高手,在线等急。


------解决方案--------------------
你请求action 但是没看到用response.getWriter().write(json);
你不response 浏览器 怎么会接受的到数据呢
------解决方案--------------------
你的json写到输出流里了么?
------解决方案--------------------
探讨

你请求action 但是没看到用response.getWriter().write(json);
你不response 浏览器 怎么会接受的到数据呢