最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

ajax傳遞多個參數(shù)的實現(xiàn)代碼

 更新時間:2016年05月13日 16:43:31   投稿:lijiao  
這篇文章主要為大家詳細(xì)介紹了ajax傳遞多個參數(shù)的實現(xiàn)代碼,簡單實用,感興趣的小伙伴們可以參考一下

本文實例為大家分享了ajax傳遞多個參數(shù)的具體代碼,供大家參考,具體內(nèi)容如下

<html >
<head>
  <title></title>
  <script src="js/Jquery1.7.js" type="text/javascript"></script>
  <script type="text/javascript">
    $(function () {


      $('#Button1').click(function () {
        var username = $('#txtUserName').val();
        var pwd = $('#txtPwd').val();
        $.ajax({
          type: "post",
          contentType: "application/json",
          url: "WebService1.asmx/Login",
          data: "{username:'" + username + "',pwd:'" + pwd + "'}",
          success: function (bukeyi) {
            if (bukeyi.d == 'true') {
              window.location = 'HTMLPage1.htm';
            }
            else {
              $('#divinfo').text("用戶名或密碼錯誤");
            }
          }
        })
      })
    })
  </script>
</head>
<body>
用戶名<input id="txtUserName" type="text" /><br />
密碼<input id="txtPwd" type="text" /><br />
  <input id="Button1" type="button" value="登錄" /><br />
  <div id="divinfo"></div>
</body>
</html>

WebService1.asmx

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;


namespace ajax11
{
  /// <summary>
  /// WebService1 的摘要說明
  /// </summary>
  [WebService(Namespace = "http://tempuri.org/")]
  [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
  [System.ComponentModel.ToolboxItem(false)]
  // 若要允許使用 ASP.NET AJAX 從腳本中調(diào)用此 Web 服務(wù),請取消對下行的注釋。
  [System.Web.Script.Services.ScriptService]
  public class WebService1 : System.Web.Services.WebService
  {


    [WebMethod]
    public string HelloWorld()
    {
      return "Hello World";
    }
    [WebMethod]
    public string ValidateUser(string username)
    {
      if (username == "onlifes")
      {
        return "用戶名已被占用,請選擇其他";
      }
      else
      {
        return "可以使用,請繼續(xù)";
      }
    }


    [WebMethod]
    public string GetDate()
    {
      return DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
    }
    [WebMethod]
    public string Login(string username, string pwd)
    {
      if (username == "admin" && pwd == "888888")
      {
        return "true";
      }
      else
      { return "false"; }


    }
  }
}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助。

相關(guān)文章

最新評論

固阳县| 元朗区| 临沭县| 鄂尔多斯市| 岢岚县| 集安市| 天等县| 集安市| 奈曼旗| 武邑县| 孙吴县| 叶城县| 绵竹市| 宿迁市| 惠东县| 青岛市| 四平市| 平顶山市| 临城县| 保德县| 舟曲县| 柯坪县| 岢岚县| 会昌县| 武陟县| 遂溪县| 方城县| 肥城市| 沾化县| 东辽县| 诸暨市| 同德县| 浑源县| 溧水县| 铜鼓县| 赣州市| 永安市| 广灵县| 清水河县| 大同县| 福贡县|