zoukankan      html  css  js  c++  java
  • ajax学习笔记(3)--$.get()方法

     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;  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

    效果图:

  • 相关阅读:
    MVC中使用AuthorizeAttribute做身份验证操作
    MVC Dynamic Authorization--示例市在Action前进行的验证,应提前到Auth过滤器
    forms
    UEditor
    Test log4net
    log4net.config
    [转]log4net使用(WinForm/WebFrom)
    如何指定模型的显示格式和模板
    64位系统中连接Access数据库文件的一个问题
    VS2008简体中文正式版序列号
  • 原文地址:https://www.cnblogs.com/hshuai/p/4272119.html
Copyright © 2011-2022 走看看