zoukankan      html  css  js  c++  java
  • jquery 执行后台方法


    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
       <script src="script/jquery-1.3.2.js" type="text/jscript"></script>
       <script type="text/jscript">
           function show(num) {
               var params = '{str:"'+ num+'"}';          
               $.ajax({
                   type: "POST",
                   url: "default.aspx/aa",
                   data: params,
                   dataType: "text",
                   contentType: "application/json; charset=utf-8",
                   beforeSend: function(XMLHttpRequest) {
                     
                       $('#show').text("正在查询");

                   },

                   success: function(msg) {

                   $('#show').text(eval("(" + msg + ")").d);
                   },
                   error: function(xhr, msg, e) { alert(msg); }
               });
          
           }
      
       </script>
    </head>
    <body>
        <form id="form1" runat="server">

        <div id="click" onclick="show('执行成功');">点击我! </div>
        <div id="show" ></div>

        </form>
    </body>
    </html>

    后台方法:

    [System.Web.Services.WebMethod()]
        public static string aa(string str)
        {
            return str;
           
        }

  • 相关阅读:
    JavaScript的执行
    关于k阶裴波那契序列的两种解法
    科普 eclipse中的Java build
    [BZOJ 1037] 生日聚会Party
    [POJ 1185] 炮兵阵地
    [POJ 1935] Journey
    [POJ 2397] Spiderman
    [POJ 2373][BZOJ 1986] Dividing the Path
    [POJ 3378] Crazy Thairs
    [POJ 2329] Nearest number-2
  • 原文地址:https://www.cnblogs.com/stulife/p/1688977.html
Copyright © 2011-2022 走看看