您的位置:首页 > 编程语言 > Java开发

ajax与struts2操作

2012-03-26 13:21 363 查看
1

$.ajax({url:'<%=request.getContextPath()%>/SysParam/selTitle.action',

async:false,

type:"get",

dataType:"json",

data:{"code":title,"rd":Math.random()},

success:function(data){

$("title").html(data.title);

}});

public void selTitle()

{

String code = getRequest().getParameter("code");

HttpServletResponse resp = getResponse();

resp.setContentType("text/html; charset=utf-8");

resp.setHeader("Cache-Control", "no-cache");

try {

Map map = new HashMap<String, Object>();

map.put("title", getText(code));

resp.getWriter().write(com.cms.common.utils.JSONUtil.formJSON(map));//JSONObject json = JSONObject.fromObject(map);

} catch (IOException e) {

LOG.error(e.getMessage());

}

}

2.通过ajax异步包含页面

$.ajax({url:'<%=request.getContextPath()%>/Role/bgcolumn.action',

async:true,

type:"get",

// dataType:"json",

data:{"rd":Math.random()},

success:function(data){

$("#submenuleft").html(data);

}});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: