jQuery对ajax的支持

2025-10-29 02:02:58

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">

jQuery对ajax的支持

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});  }); })

jQuery对ajax的支持

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

jQuery对ajax的支持

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>

jQuery对ajax的支持

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();  

jQuery对ajax的支持

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¥");   }  } }}

jQuery对ajax的支持

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢