<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>AJAX--实现--JQuery实现方式--get</title> <script src="js/jquery-3.3.1.min.js"></script> </head> <body> <script> function btn_ajax() { $.get("AjaxServlet", {name: "get"}, function (data) { $("#myDiv").innerHTML = data alert(data) }, "text") } </script> <input type="button" value="发送异步请求" onclick="btn_ajax()"> <span id="myDiv"></span> <input> </body> </html> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>AJAX--实现--JQuery实现方式--post</title> <script src="js/jquery-3.3.1.min.js"></script> </head> <body> <script> function btn_ajax() { $.post("AjaxServlet", {name: "post"}, function (data) { $("#myDiv").innerHTML = data alert(data) }, "text") } </script> <input type="button" value="发送异步请求" onclick="btn_ajax()"> <span id="myDiv"></span> <input> </body> </html>