我是 jQuery 的新手,不了解 jQuery Ajax 是如何返回数据的。我有一些简单的函数来获取如下所示的一些数据
[WebMethod(EnableSession = false)]
protected int SignIn()
{
return 0;
}
在我的 .aspx 页面中有这个
$(document).ready(function () {
$("#si").click(function
() {
$.ajax({
type: "POST",
url: "SignIn.aspx/SignIn",
contentType: "application/json",
success: function (txt) {
alert(txt);
}
});
});
});
但在警报中我得到了整个 SignIn.aspx(所有 html 标记等)。如何提醒 SignIn() 返回的 0?谢谢
最佳答案
将 SignIn
方法设为静态和公开,并使用以下代码显示警报:alert(txt.d);
关于c# - 在 Asp.Net 中获取 jQuery Ajax 返回数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8094112/