博客
关于我
jQuery 调用 Ajax 实现查询的局部更新 (jsp + servlet + jQuery + Ajax)
阅读量:393 次
发布时间:2019-03-05

本文共 1785 字,大约阅读时间需要 5 分钟。

jQuery?Java Servlet??AJAX???????

???????????jQuery??Java Servlet?????????????????????????

??????

???????????HTML????????????

  • ??????????????
  • ????????AJAX??
  • ??????????????????

???????

    

????????

??????Java Servlet??????????

  • ???????????
  • ????????????
  • ?????????
  • ???????

    package com.syrdbt.system.servlet;import javax.servlet.ServletException;import javax.servlet.annotation.WebServlet;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import java.io.IOException;@WebServlet("/TestAjaxServlet")public class TestAjaxServlet extends HttpServlet {    protected void doGet(HttpServletRequest request, HttpServletResponse response)            throws ServletException, IOException {        request.setCharacterEncoding("utf-8");        String name = request.getParameter("info");        System.out.println("?????? " + name);                if(name.equals("abc")) {            response.getWriter().print("success");        } else {            response.getWriter().print("failed");        }    }        protected void doPost(HttpServletRequest request, HttpServletResponse response)            throws ServletException, IOException {        doGet(request, response);    }}

    ??????

  • HTML????

    • ????jQuery?
    • ?????????ID???JavaScript??
  • JavaScript????

    $(function() {    $("#search").click(function() {        var value = $("#info").val();        $.ajax({            type: 'POST',            url: "TestAjaxServlet",            data: "info=" + value,            success: function(result) {                $("#show").html(result);            }        });    });});
  • ????????

    • ???????
    • ????????
    • ????
  • ?????

    ?????????????

  • ???????
  • ??????AJAX??
  • ???????????
  • ??????????
  • ??????????????????????????????HTML???????????????

    转载地址:http://fpkzz.baihongyu.com/

    你可能感兴趣的文章
    python 学习 面向对象编程
    查看>>
    Python 学习日记第三篇 -- 字典
    查看>>
    Python 学习笔记(一)Data type
    查看>>
    python 安装echarts
    查看>>
    python 安装opencv及问题解决
    查看>>
    Python 安装程序:“写入文件 C:\Python27\pythonw.exe 时出错“
    查看>>
    Python 安装避坑指南:从入门到进阶
    查看>>
    Python 安装配置详解
    查看>>
    python 实现儿童算术游戏
    查看>>
    python 实现字符串转整型
    查看>>
    Python 实现定时任务的八种方案!
    查看>>
    Python 实现自动化测试 dubbo 协议接口
    查看>>
    python 对json数据读取及保存与读取,对dump,dumps,load,loads的理解
    查看>>
    Python 对mysql数据库的操作
    查看>>
    Python 对象数据库列表
    查看>>
    Python 导入requests报错No module named requests
    查看>>
    python 将函数加到列表中进行调用
    查看>>
    python 将图片与字符串相互转换
    查看>>
    Python 嵌套字典全面指南
    查看>>
    Python 常见的错误类型和继承关系
    查看>>