1.jquery的load方法:
1.前台页面: <form id="queryForm"> <div class="cbim_nav"> <ul> <li class="cbim_nav_title">管理单位名称</li> <li> <s:select list="#request.imList" label="" id="im" listKey="orgId" listValue="orgname" value="#request.currentKey"></s:select> </li> <li class="cbim_nav_cx"><a href="javascript:void(0)" onclick="queryImorg()">查询</a></li> </ul> </div> </form> <div id="load"></div> Js文件: <script type="text/javascript"> /* *执行查询条件,查询下属机构信息 */ function queryImorg(){ var orgId = $("#im option:selected").val(); if(orgId!=null || orgId!=""){ $('#load').load('imorg/ImorgAction!querySingleImorg.action',{ orgId:orgId, }); } } $(function(){ queryImorg(); }) </script> 2.后台action处理: public String querySingleImorg() throws Exception{ im=imorgbService.selectImOrgB(orgId); request.setAttribute("im", im); //获取该单位上传的图片 List<ImFilemgB> list=new ArrayList<ImFilemgB>(); this.setFilefkuuid(im.getFilefkuuid()); fileList=imfilemgbService.selectImFilemgBy(filefkuuid); request.setAttribute("num", fileList.size()); request.setAttribute("fileList", fileList); request.setAttribute("show", true); return "querySingleImorg"; } 3.struts配置文件: <result name="querySingleImorg">/WEB-INF/pages/sm/imorg/imorgView.jsp</result>
2.ajax函数调用:
$.ajax({
type: 'post',//get,post请求
data: str,//传递的参数,数据类型为:{key:value,key2:value2}
url : "osbim/OsbimAction!deleteOsbim.action",//路径
contentType : "application/json; charset=utf-8",
success : function(data) {//回调函数
if("delete"==data){
$.messager.alert("消息", "删除成功");
queryList();
}else{
$.messager.alert("消息", "操作失败");
}
}
error:function(){
$.messager.alert("消息","操作失败");
}
});
如果type类型为get,则可以在url后传递参数