比较好的jquery 请求action加载select的例子
/**
*查询检测记录(异步请求)
*@return
*/
publicvoidfind(){
HttpServletResponseresponse=ServletActionContext.getResponse();
HttpServletRequestrequest=ServletActionContext.getRequest();
response.setContentType("text/xml");
response.setCharacterEncoding("GB2312");
PrintWriterwriter=null;
//分页信息
PageBeanpage=newPageBean();
page=PageHandler.initPage();
if(index!=null){
page.setGotoPage(index);
}
try{
request.setCharacterEncoding("iso-8859-1");
writer=response.getWriter();
view=recordService.findRecordByCondition(recordForm,page);//调用底层接口返回数据
StringBufferbuffer=ActionBean.getRecordQueryString(view,request);//进行数据封装(html)
writer.write(buffer.toString());
}catch(Exceptione){
e.printStackTrace();
}finally{
if(writer!=null)
writer.close();
}
response.setHeader("Charset","GB2312");
response.setHeader("Cache-Control","no-store");
response.setHeader("Pragma","no-cache");
response.setDateHeader("Expires",0);
}
配置文件:
<!--查询历史检测记录-->
<actionname="find"class="com.sclead.web.action.record.RecordAction"method="find"/>
页面JS函数:
//查询历史记录
functionqueryRecord(index){
varform=document.getElementById("find");
form.x_index.value=index;//页码
//参数
varparameter="depid="+form.depId.value+"&devid="+form.devId.value+
"&locoType="+form.locoType.value+"&locoNO="+form.locoNO.value+
"&panType="+form.panType.value+"&isLoad="+form.isLoad.value+
"&startTime="+form.startTime.value+"&endTime="+form.endTime.value+
"&index="+index+"&flag=2";
$.ajax({
type:"GET",
url:"<%=path%>/record/find",
dataType:'html',
cache:false,
data:parameter,
success:function(text){
//执行成功以后动态替换也页面内容,因为返回的格式为Html,直接显示即可
document.getElementById("content").innerHTML=text;
}
});
}