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

首頁 > 開發 > AJAX > 正文

ajax傳遞多個參數具體實現

2024-09-01 08:26:40
字體:
來源:轉載
供稿:網友
復制代碼 代碼如下:www.mb5u.com

<!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----
復制代碼 代碼如下:www.mb5u.com

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 從腳本中調用此 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"; }
}
}
}

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 墨竹工卡县| 宁陕县| 江永县| 雷山县| 师宗县| 七台河市| 朝阳县| 楚雄市| 舞阳县| 玉门市| 花垣县| 大厂| 固原市| 无极县| 武威市| 武功县| 贵阳市| 泽州县| 楚雄市| 偏关县| 舞阳县| 钦州市| 额济纳旗| 玛纳斯县| 板桥市| 安庆市| 九江市| 商水县| 安西县| 璧山县| 金川县| 揭西县| 淅川县| 尖扎县| 曲水县| 曲阳县| 新余市| 盘锦市| 兰考县| 英山县| 上蔡县|