当前位置: 动力学知识库 > 问答 > 编程问答 >

asp.net - jQuery Ajax not calling webmethod after url rewriting

问题描述:

My jQuery AJAX function is not calling my webmethod. Here is my code:

$.ajax({

type: "POST",

url: "Search.aspx/GetCustomers",

data: '{pageIndex:' + pageIndex + ',searchText:"' + $('#HiddenField1').val() + '",SearchBy:"' + $('#ddlSelectProfile').val() + '"}',

contentType: "application/json; charset=utf-8",

dataType: "json",

success: OnSuccess,

failure: function (response) {

alert(response.d);

},

error: function (response) {

alert(response.d);

}

});

[WebMethod]

public static string GetCustomers(int pageIndex, string searchText, string SearchBy)

{

return GetCustomersData(pageIndex,searchText, SearchBy ).GetXml();

}

and in web.config

<rewrite url="~/Search/(.+)-(.+).html" to="~/Search.aspx?MyTitleId=$1&amp;page=$2" processing="stop" />

网友答案:

In javascript change "url: "Search.aspx/GetCustomers"" to "url: "Search/GetCustomers"," you are fobidding the access to *.aspx with this rule ;)

分享给朋友:
您可能感兴趣的文章:
随机阅读: