【发布时间】:2014-06-27 08:45:18
【问题描述】:
这是我的 ajax 调用
$(document).ready(function () {
$("#btnSubmit").click(function () {
alert("I am in ?");
$.ajax({
type: "POST",
url: "TestNew2.aspx/DisplayData",
data: "{}",
contentType: "application/x-www-form-urlencoded",
dataType: "text",
//success: function (msg) {
// // Replace the div's content with the page method's return.
// $("#btnSubmit").text(msg.d);
// alert(msg.d);
//}
success: function (result, status, xhr) {
document.getElementById("lblOutput").innerHTML = xhr.responseText
},
error: function (xhr, status, error) {
alert(xhr.error);
}
});
});
});
还有我的网络方法[WebMethod]
public static string DisplayData()
{
return DateTime.Now.ToString();
}
尝试在 aspx 页面上调用 web 方法时获取 aspx 页面。这里是 jQuery 代码 谁能指出可能出了什么问题。因为没有调用网络方法。
【问题讨论】: