首页 > Web开发 > 详细

jQuery $get()与$post简单用法

时间:2016-08-27 16:53:37      阅读:320      评论:0      收藏:0      [点我收藏+]
//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>");
%>


本文出自 “11820140” 博客,请务必保留此出处http://11830140.blog.51cto.com/11820140/1843184

jQuery $get()与$post简单用法

原文:http://11830140.blog.51cto.com/11820140/1843184

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!