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

首頁 > 開發(fā) > AJAX > 正文

ajax傳遞多個參數(shù)具體實現(xiàn)

2024-09-01 08:29:06
字體:
供稿:網(wǎng)友
代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<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 從腳本中調(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"; }
}
}
}
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 江口县| 古交市| 大厂| 凤山市| 平武县| 江油市| 虞城县| 建阳市| 合水县| 西乌珠穆沁旗| 宁明县| 安徽省| 阳东县| 青龙| 丹凤县| 新乐市| 香港| 电白县| 阆中市| 峨眉山市| 石狮市| 漠河县| 阿克| 新丰县| 浮梁县| 石河子市| 伊宁县| 茌平县| 山丹县| 榆树市| 冕宁县| 瑞丽市| 满洲里市| 莱阳市| 青州市| 灵石县| 萍乡市| 金川县| 五寨县| 佳木斯市| 镇巴县|