问题描述:

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 ;)

相关阅读:
Top