ajax中怎么傳遞多個參數(shù)-創(chuàng)新互聯(lián)

今天就跟大家聊聊有關(guān)ajax中怎么傳遞多個參數(shù),可能很多人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。

創(chuàng)新互聯(lián)建站從2013年創(chuàng)立,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項目網(wǎng)站設(shè)計制作、網(wǎng)站制作網(wǎng)站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元隆陽做網(wǎng)站,已為上家服務(wù),為隆陽各地企業(yè)和個人服務(wù),聯(lián)系電話:18982081108

具體內(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 = "/tupian/20230522/
  [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)容,你們對ajax中怎么傳遞多個參數(shù)有進一步的了解嗎?如果還想了解更多知識或者相關(guān)內(nèi)容,請關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝大家的支持。

分享標題:ajax中怎么傳遞多個參數(shù)-創(chuàng)新互聯(lián)
網(wǎng)站地址:http://bm7419.com/article42/hcchc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供云服務(wù)器網(wǎng)站設(shè)計公司、企業(yè)建站、網(wǎng)站維護、ChatGPT、外貿(mào)網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

綿陽服務(wù)器托管