jquery发送ajax请求
$.ajax({ type:"POST", url:"getPsNewConsultList.action", error : function(textStatus, errorThrown) { //失败 $.messager.alert('错误', "系统ajax交互错误: " + textStatus, 'error'); }, success:function(){ //成功 }
jquery的json函数
//加载新回复提示链接 $.getJSON("getPsNewReplyPrompt.action",function add(json){ json=eval(json.replyList); for(var i=0;i<json.length;i++) { //alert(json[i]); //$("#zx").append("<a οnclick='setReplyPrompt("+json[i]+");' href='jsp/proposal/psconsultview.jsp?documentnumber="+json[i]+"'>"+json[i]+"有新回复</a>  "); var buffer=new StringBuilder(); buffer.append("<a οnclick='setReplyPrompt("+json[i].documentnumber+");' href='jsp/proposal/psconsultview.jsp?documentnumber=") buffer.append(json[i].documentnumber); buffer.append("'>"); buffer.append(json[i].documentnumber); buffer.append("有新回复</a>  "); $("#zx").append(buffer.toString()); } } );
replyList 是返回的一个list
格式如下
//ajax加载数据
for(int i=pageRows*(this.getPage()-1);i>=pageRows*(this.getPage()-1)&&i<=pageRows*this.getPage();i++)
{
person=new Person();
person.setId(i);
person.setName("名字"+i);
replyList.add(person);
}
........
return replyList;
当然不要忘记strutsxml中配置返回json数据