【发布时间】:2013-08-17 13:32:03
【问题描述】:
我在 asp.net 中进行 JQuery Ajax 调用,我正在使用我的 WebMethod 返回字符串,但是在 ajax 调用成功时,我在结果中获得了页面的完整 HTML。我还使用了类型:“get”但没有运气,下面是我的ajax调用代码
$.ajax({
type: "POST",
url: "MyPage.aspx/GetData", //url to point your webmethod
success: function (Result) {
if (Result != "")
alert( Result);
},
error: function () { alert('error'); }
});
[System.Web.Services.WebMethod()]
public string GetData()
{
//getting value from Database and returning
}
我在 MyPage.aspx 中调用这个 Ajax
【问题讨论】:
-
可以发一下webmethod吗?
-
@Xikinho90 我也发布了方法,GetData()