Использование запроса ajax для вызова веб-метода на странице ASP.NET хорошо работает, если запрос HTTP является POST Если используется HTTP-запрос GET, вместо веб-метода запускается событие Page_Load.
Есть идеи?
Вот этот Аякс
$.ajax({
type: "GET",
url: "http://local.proleaguesports.pagefad.com/AjaxTesting.aspx/receivermethod",
data: "{'test':'MyName'}",
contentType: "application/json",
dataType: "json",
success: mycallback,
error: handler
});
И вот код в C #
public partial class AjaxTesting : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("Page_Load runs instead of the receivermethod below");
}
[WebMethod]
[ScriptMethod(UseHttpGet = true)]
public static string receivermethod()
{
return "test received";
}
}