随笔 - 130  文章 - 1  评论 - 16  阅读 - 12万 
复制代码
 1 <head runat="server">
 2     <title>jQuery中的$.get()方法</title>
 3     <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
 4     <script type="text/javascript">
 5         $(function () {
 6             $("#send").click(function () {
 7                 $.get(
 8             "get.aspx", //url
 9             {username: $("#username").val(),
10             content: $("#content").val()
11         }, //data
12              function (data, textStatus) {
13                  $("#resText").html(data);
14 
15              } //回调函数
16            )
17          });
18         });      
19     </script>
20 </head>
21 <body>
22     <form id="form1" runat="server" style="border: 1px solid grey; width: 300px;">
23     <div>
24         <p>
25             评论:</p>
26         <p>
27             姓名:<input type="text" name="username" id="username" /></p>
28         <p>
29             内容:<textarea name="content" id="content" rows="2" cols="20"></textarea></p>
30         <p>
31             <input type="button" id="send" value="提交" /></p>
32     </div>
33     <div class="comment">
34         已有评论:
35         <div id="resText">
36         </div>
37     </div>
38     </form>
39 </body>
View Code
复制代码
复制代码
 1 public partial class get : System.Web.UI.Page
 2     {
 3         protected void Page_Load(object sender, EventArgs e)
 4         {
 5             string userName=Request.QueryString["username"];
 6             string content = Request.QueryString["content"];
 7 
 8             //服务器返回内容的格式:html,xml,script,json,text,和_default
 9             //这里使用的是html格式
10             string backContent = "<p>姓名: "+userName+"<br/>内容: "+content+"</p>";
11             Response.Write(backContent);
12         }
13     }
View Code
复制代码

效果图:

 

posted on   水语者9  阅读(204)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
点击右上角即可分享
微信分享提示