亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

JavaScript用JQuery呼叫Server端方法實(shí)現(xiàn)代碼與參考語法

 更新時(shí)間:2013年01月23日 09:11:51   作者:  
從Javascript客戶端用JQuery呼叫Server端的方法,這也是一個(gè)大膽的嘗試,本人做了演示動(dòng)畫以及參考語法,感興趣的朋友可以參考下,希望本人對(duì)你有所幫助
Insus.NET從2013年開始學(xué)習(xí)Javascript,此博文是第一次使用JQuery,從Javascript客戶端用JQuery呼叫Server端的方法。首先看看此例的演示
 
準(zhǔn)備好Server端的方法
復(fù)制代碼 代碼如下:

[System.Web.Services.WebMethod]
public static string VeryUserName(string name)
{
string rtn = "恭喜,此帳號(hào)還沒有注冊,你可以使用。";
if (name == "")
rtn = "請?zhí)顚懸粋€(gè)注冊帳號(hào)。";
if (name == "Insus.NET")
rtn = "此用戶已經(jīng)注冊,請使用另外帳號(hào)。";
return rtn;
}

HTML代碼
復(fù)制代碼 代碼如下:

Account:
<asp:TextBox ID="TextBoxAccount" runat="server"></asp:TextBox><br />
<input id="btnrReg" type="button" value="注冊" onclick="VeryRegAccount()" />

Javascript腳本:
復(fù)制代碼 代碼如下:

<script src="scripts/jquery-1.3.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
function VeryRegAccount() {
$.ajax({
type: "POST",
url: "Default.aspx/VeryUserName",
data: '{name: "' + $("#<%= TextBoxAccount.ClientID%>")[0].value + '" }',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.d);
}
});
}
function OnSuccess(response) {
alert(response.d);
}
</script>

可參考下面語法

相關(guān)文章

最新評(píng)論