欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jQuery調(diào)用WebMethod(PageMethod) NET2.0的方法

 更新時(shí)間:2016年04月15日 11:24:15   作者:jarryzhong  
這篇文章主要介紹了jQuery調(diào)用WebMethod(PageMethod) NET2.0的方法,結(jié)合實(shí)例形式分析了jQuery基于ajax調(diào)用.NET方法的相關(guān)技巧,需要的朋友可以參考下

本文實(shí)例講述了jQuery調(diào)用WebMethod(PageMethod) NET2.0的方法。分享給大家供大家參考,具體如下:

首先必須在WebConfig下的system.web節(jié)點(diǎn)加入此配置信息

<httpModules>
   <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</httpModules>

ScriptMethod(ResponseFormat = ResponseFormat.Json)]
[WebMethod]
/// <summary>
/// 是否允許注冊
/// </summary>
/// <param name="MemberLoginID"></param>
/// <returns></returns>
public static MemberInfo AllowRegist(string MemberLoginID)
{
    return new MemberInfo();//由于設(shè)置了返回類型是JSON,所以客戶端的JQ能夠識(shí)別
    // MemberInfoBLL mi = new MemberInfoBLL();
    //if (!mi.ExistMember(MemberLoginID))
      //return "{d:true}";//我測試發(fā)現(xiàn),客戶段在接收數(shù)據(jù)的時(shí)候,會(huì)多了2個(gè)雙引號,導(dǎo)致轉(zhuǎn)換JSON格式失敗..郁悶
    //else
      //return "{d:false}";
}

$.ajax({
    cache:false,
    type: 'POST',
    contentType: 'application/json; charset=utf-8',
    data: "{'MemberLoginID':'" + $("#<%=MemberLoginID.ClientID %>").val() + "'}",
    dataType: 'json',
    url: 'Reg.aspx/getDate',
    success: function(result,x,y) {
      alert(result);
    },
    beforeSend:function (xhr) {
      xhr.setRequestHeader('If-Modified-Since', '0');
      //this; // 調(diào)用本次AJAX請求時(shí)傳遞的options參數(shù)
    },
    error: function(e) {
      debugger; //alert("可能服務(wù)器忙沒有返回?cái)?shù)據(jù),請重試");
    }
});

更多關(guān)于jQuery相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jQuery遍歷算法與技巧總結(jié)》、《jQuery表格(table)操作技巧匯總》、《jQuery拖拽特效與技巧總結(jié)》、《jQuery擴(kuò)展技巧總結(jié)》、《jQuery常見經(jīng)典特效匯總》、《jQuery動(dòng)畫與特效用法總結(jié)》、《jquery選擇器用法總結(jié)》及《jQuery常用插件及用法總結(jié)

希望本文所述對大家jQuery程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評論