我有一個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
對不起,「不起作用」表示該方法未被調用。 –