国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > AJAX > 正文

ajax傳遞多個參數的實現代碼

2024-09-01 08:27:59
字體:
來源:轉載
供稿:網友

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

<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 從腳本中調用此 Web 服務,請取消對下行的注釋。  [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 "可以使用,請繼續";      }    }    [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"; }    }  }}

以上就是本文的全部內容,希望對大家的學習有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 甘泉县| 文安县| 无棣县| 巨野县| 扎赉特旗| 文登市| 涟水县| 屯昌县| 丹东市| 达州市| 深泽县| 中卫市| 沙田区| 阿城市| 宝清县| 罗城| 邵阳县| 杂多县| 贡嘎县| 堆龙德庆县| 平阳县| 西畴县| 岱山县| 徐闻县| 平罗县| 新昌县| 平顶山市| 永仁县| 临汾市| 遂昌县| 广饶县| 县级市| 顺义区| 台东县| 镇安县| 嵊泗县| 恩施市| 佛冈县| 商南县| 福海县| 延川县|