$.ajax({
url:"${pageContext.request.contextPath}/ad/packAction!pack.action", //请求路径
type:'POST',//请求方式
cache: false,//清除缓存
dataType:"json",//数据类型是json类型数据
data:{ //下面的是你要发送到服务器端的数据
types:types,
packageNames:packageNames
},
success:function(re){
$("#"+re.type).html(re.packageName);//对页面的操作
$("#"+re.type+"_download").attr("class","tjyy");//对页面的操作
},
error:function(XMLHttpRequest, textStatus, errorThrown){
}
});
服务器返回页面代码:
PrintWriter out = null;
JSONObject obj = new JSONObject();
try {
out = response.getWriter();
response.setContentType("text/html;charset=UTF-8");
obj.put("返回客服端的key", 返回客服端的value);
out.print(obj);
out.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
}