简单的ajax动态级联菜单
|
一、处理请求的JSP文件 menujsp.jsp <%@ page contentType="text/html; charset=GBK" %> <% //接收浏览器端提交的信息 String sort=request.getParameter("sort"); String contents1=""; String contents2=""; if(sort.equals("IBM")){ contents1="IBM笔记本1"; contents2="IBM笔记本1"; }else if(sort.equals("SONY")){ contents1="SONY笔记本1"; contents2="SONY笔记本2"; } //传回响应数据 response.setContentType("text/xml; charset=UTF-8"); response.setHeader("Cache-Control", "no-cache"); out.println(""); out.println("" + contents1 + ""); out.println("" + contents2 + ""); out.println(""); out.close(); %> |
二、发送请求的:menu.html
cellSpacing=0 cellPadding=0 width=200 bgColor=#f5efe7 border=0>
笔记本品牌
|
IBM
|
|
SONY
|
|
[实例讲解]
处理客户端的请求先将上传回来的信息处理好了之后开始往客户端输出
response.setContentType("text/xml; charset=UTF-8");
response.setHeader("Cache-Control", "no-cache");
out.println("
");
out.println("" + contents1 + "");
out.println("" + contents2 + "");
out.println("");
out.close();
阅读(1287) | 评论(0) | 转发(0) |