ajax传递多个参数具体实现

时间:2016.04.19 发布人:**didaon71v

ajax传递多个参数具体实现

已解决问题

谷歌**didaon71v用户在2016.04.19提交了关于“维他奶被拒ajax传递多个参数具体实现”的提问,欢迎大家涌跃发表自己的观点。目前共有1个回答,最后更新于2025-02-25T13:32:24。希望大家能够帮助她。

详细问题描述及疑问:期待您的答案,我不知道说什么才好,除了谢谢 !

希望以下的回答,能够帮助你。

第1个回答

用户名:prof331215问答essortoby  

复制代码代码如下:
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXh**即TML1.0Transitional//EN""http://www.***.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns副免挥规南="http:/起读副苏时术政县/www.***.org/1999/xhtml">
<head>
<title></title>
<scriptsrc="js/Jquery1.7.js"type="text/j**ascript"></script>
<scripttype="text/j**ascri怎怎年工便都国重树pt">
$(func地因参tion(){
$('#Button1').click(function(){
其varusername=$('#txtUserName').val();
varpwd=$('#t简先来资xtPwd').val();
$.ajax({
type:"post",
contentType:"application/json",
url:"WebService1.a**x/Login",
data:"{username:'"+username+"',pwd:'"+pwd+"'}",
success:function(bukeyi){
if(b由祖其杀紧候ukeyi.d=='tr降创ue'){
window.location='h**TMLPage1.htm';
}
el项se{
$('#divinfo').text("用户名或密码错误");
}
}
})
})
})
</script>
</head>
<body>
用户名<inputid="txtUserName"type="te视垂延xt"/><br/>
密码<inputid="txtPwd"type="text"/><br/>
<inputid="Button1"type="button"娘华项节口value="登录"打农哪七占察看地/><br/>
<divid="divinfo"></div>
</body>
</html>

------WebService1.a**x-外市代套断图---
复制代码代码如既下:
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Web;
usingSystem.***.Services;
namespaceajax11
{
///<summary>
///WebServi石处杀虽数值ce1的摘要说明
///</summary>
[WebService(Namespace="h封ttp://***.org/")]
[WebServiceBinding(ConformsTo=WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
//若要允许使用***.NETAJAX从脚本中调用此Web服务,请取消对下行的注释。
[System.Web.Script.Services.ScriptService]
publicclassWebService1:System.***.Services.WebService
{
[WebMethod]
publicstringh**elloWorld()
{
return"h**elloWorld";
}
[WebMethod]
publicstringValidateUser(stringusername)
{
if(username=="onlifes")
{
return"用户名已被占用,请选择其他";
}
else
{
return"可以使用,请继续";
}
}
[WebMethod]
publicstringGetDate()
{
returnDateTime.Now.ToString("yyyy-MM-ddhh:mm:ss");
}
[WebMethod]
publicstringLogin(stringusername,stringpwd)
{
if(username=="admin"&&pwd=="888888")
{
return"true";
}
else
{return"false";}
}
}
}