vlambda博客
学习文章列表

Ajax_04|使用jQuery演示get方法




 



Ajax_04|使用jQuery演示get方法


Ajax_04|使用jQuery演示get方法




Ajax_04|使用jQuery演示get方法

    package com.tx.servlet;

    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    public class DemoServlet03 extends HttpServlet {

        public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {


            response.setContentType("text/html;charset=utf-8");
            response.getWriter().write("给你一份数据");
        }

        public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            doGet(request, response);
        }
    }



 


Ajax_04|使用jQuery演示get方法

Ajax_04|使用jQuery演示get方法

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
      <display-name>Ajax_02_load</display-name>
      <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
      </welcome-file-list>
      <!-- 这些servlet代码是创建servlet时自动生成的 -->
      <servlet>
        <description></description>
        <display-name>DemoServlet03</display-name>
        <servlet-name>DemoServlet03</servlet-name>
        <servlet-class>com.tx.servlet.DemoServlet03</servlet-class>
      </servlet>
      <servlet-mapping>
        <servlet-name>DemoServlet03</servlet-name>
        <url-pattern>/DemoServlet03</url-pattern>
      </servlet-mapping>
    </web-app>



 


Ajax_04|使用jQuery演示get方法

Ajax_04|使用jQuery演示get方法

    <%@ 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">
    <script type="text/javascript" src="js/jquery-1.11.3.min.js"></script>

    <script type="text/javascript">

        //get请求表达式:  $.get(URL,callback);

        function get({
            $.get("/Ajax_03_get/DemoServlet03"  , function(data ,status{
                alert("结果是:"+data);
                //$("#div01")  -->  document.getElementById("div01");

                //$("#div01").html(data);
                $("#div01").text("aaa="+data);
            });
        }
    
</script>
    <title>Insert title here</title>
    </head>
    <body>

        <input type="button" onclick="get()" value="使用JQuery演示 get方法">
        <div id="div01"  style="width: 100px ; height: 100px ; border: 1px solid blue; "></div>

    </body>
    </html>



目录大纲 Directory outline