DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> AJAX入門 >> AJAX基礎知識 >> ajax 登錄功能簡單實現(未連接數據庫)
ajax 登錄功能簡單實現(未連接數據庫)
編輯:AJAX基礎知識     
簡單的登錄功能(未連接數據庫)
復制代碼 代碼如下:
<script src="Jquery1.7.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$('#tijiao').click(function () {
var username = $('#username').val();
var pwd = $('#pwd').val();
$.ajax({
type: "post",
contentType: "application/json",
url: "WebService1.asmx/denglu",
data: "{username:'" + username + "',pwd:'" + pwd + "'}",
success: function (bukeyi) {
$('#tishi').text(bukeyi.d);
}
})
})
})
</script>
</head>
<body>
用戶名:<input type="text" id="username" runat="server" />
密碼:<input type="text" id="pwd" runat="server" />
<input type="button" id="tijiao" value="提交" />
<div id="tishi"></div>
[WebMethod]
public string denglu(string username,string pwd)
{
if (username == "zhangsan" && pwd == "123")
{
return "登陸成功!";
}
else { return "登陸失敗!"; }
}
XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved