//get1、html 数据格式为html <script language="javascript" > $(function(){ $("#send").click(function(){ $.get("get1.jsp", { username : $("#username").val(), content : $("#content").val() }, function (data, textStatus){ $("#resText").html(data); // 把返回的数据添加到页面上 } ); }) }) </script> <form id="form1"> <p>评论:</p> <p>姓名: <input type="text" name="username" id="username" /></p> <p>内容: <textarea name="content" id="content" ></textarea></p> <p><input type="button" id="send" value="提交"/></p> </form> <div class=‘comment‘>已有评论:</div> <div id="resText" > </div> // get1、jsp <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% String username = request.getParameter("username"); String content = request.getParameter("content"); out.println("<div class=‘comment‘><h6> "+username+" :</h6><p class=‘para‘> "+content+" </p></div>"); %>
时间: 2024-11-07 01:05:09