Home  >  Article  >  Web Front-end  >  How to pass multiple parameters using ajax

How to pass multiple parameters using ajax

php中世界最好的语言
php中世界最好的语言Original
2018-04-04 15:02:466248browse

This time I will show you how to use ajax to pass multiple parameters, and what are the precautions for using ajax to pass multiple parameters. The following is a practical case, let's take a look.

The example in this article shares the specific code for ajax to pass multiple parameters for your reference. The specific content is as follows



  
  
  

用户名
密码
  
  

WebService1.asmx

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
namespace ajax11
{
  /// 
  /// WebService1 的摘要说明
  /// 
  [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"; }
    }
  }
}
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

Jump to the login page immediately after Ajax+Session fails

How to deal with Session failure when accessed by ajax

The above is the detailed content of How to pass multiple parameters using ajax. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn