我有一个webforms应用程序,需要在我的aspx页面后面的代码中对PageMethod(即WebMethod)进行jquery ajax调用。到目前为止,它不适合我。这可能吗? 这里是我的代码:从aspx页面访问PageMethod
$(function()
{
setInterval(function(){
$.ajax({
type: "GET",
url: "/ClientBillingBillDetails.aspx/MyPageMethod",
data: {someData: '<%= TheData %>'},
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(result) {
}
});
}, 10000);
});
[System.Web.Services.WebMethod]
public static string MyPageMethod(int someData)
{
return "";
}
什么毛病我的网址或其他什么东西?
感谢
有许多文章在那里。检查[这](http://stackoverflow.com/questions/7770679/jquery-ajax-call-to-an-asp-net-webmethod),[这](http://www.aspsnippets.com/Articles/ Calling-ASPNet-WebMethod-using-jQuery-AJAX.aspx)and [this](http://stackoverflow.com/questions/6928533/calling-a-webmethod-with-jquery-in-asp-net-webforms) – techspider
“不起作用”是什么意思?请准确描述您所看到的行为以及您期望看到的内容。在浏览器中包含调试和检查控制台和网络选项卡的相关信息。 – mason
对不起,“不起作用”表示该方法未被调用。 –