【发布时间】:2014-08-23 13:33:05
【问题描述】:
我有一个像下面这样的 asp.net 网络方法
[WebMethod]
public string getDate()
{
return DateTime.Now.ToString();
}
我的 jQuery ajax 调用如下
$.ajax({
type: "POST",
url: "jqueryAjax/Default.aspx/getDate",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
error: function (XMLHttpRequest, textStatus, errorThrown)
{
alert(errorThrown+"what's wrong?"+XMLHttpRequest);
},
success: function (msg)
{
alert(msg);
// Do something interesting here.
}
});
由于某种原因,我的 jQuery ajax 错误处理程序被调用。成功方法没有调用。
我们将不胜感激。
谢谢
【问题讨论】:
-
errorThrown的值是多少? -
@JustinIurman 抛出的错误是 [object Object]
-
嗯,我的意思是,你得到什么错误信息进入那个对象?另外,您是否通过
domain.com/jqueryAjax/Default.aspx/getDate访问您的网络方法? -
@JustinIurman 我该如何检查?
-
console.log(errorThrown);甚至更好的console.dir(errorThrown);并查看浏览器的控制台以获取您的对象
标签: jquery asp.net ajax webmethod