[英]Ajax Call in asp.net
我在asp.net中进行JQuery Ajax调用,使用WebMethod返回String,但是在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
这样尝试。 使用contentType:“ application / json; charset = utf-8”
$.ajax({
type: "POST",
url: "MyPage.aspx/GetData", //url to point your webmethod
contentType: "application/json; charset=utf-8",
success: function (Result) {
if (Result != "")
alert( Result);
},
error: function () { alert('error'); }
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.