jQuery对ajax的支持
1、<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

2、<script type="text/javascript"> $(function(){ $('a[class=s1]').click(function(){ var flight = $(this).parent().siblings().eq(0).text(); $(this).next().load('order.do',{'flight':flight}); }); })

3、 <table cellpadding='0' cellspacing='0' width='80%' border='1px'> <thead> <tr> <td>航班号</td> <td>机型</td> <td>票价</td> </tr> </thead> <tbody> <tr>

4、 <td>CA747</td> <td><a href="#">波音客机</a></td> <td> <a href="javaScript:;" class='s1'>查看所有票价</a> <div></div> </td> </tr> <tr> <td>MU193</td> <td><a href="#">空客客机</a></td> <td> <a href="javaScript:;" class='s1'>查看所有票价</a> <div></div> </td> </tr> </tbody> </table>

5、public class ActionServlet extends HttpServlet{ @Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //post请求,解决乱码 request.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); //获取请求地址 PrintWriter out=response.getWriter(); String path=request.getRequestURI();

6、String action=path.substring(path.lastIndexOf("/"),path.lastIndexOf(".")); if(action.equalsIgnoreCase("/order")){ String flight=request.getParameter("flight"); if(flight.equals("CA747")){ out.println("经济舱:345¥</br>头等舱:556¥"); }else{ out.println("经济舱:432¥</br>头等舱:879¥"); } } }}
