ajax多个参数怎么传递,ajax传递多个参数具体实现

$(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("用户名或密码错误");

}

}

})

})

})

用户名

密码

------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"; }

}

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值