我有这个 jquery 代码
$("#ProfileBtn").click(function () {
if (true) {
$.ajax({
type: "POST",
url: "sMaster.Master/outClick",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function () {
alert("~");
location.reload();
},
error: function () {
alert("!");
}
});
}
});
调用 asp.net 函数:
[ScriptMethod, WebMethod]
public static void outClick()
{
}
当我使用 chrome 或 firefox 尝试时,一切都很好(警报(“~”)),但在 Internet Explorer 上它失败了(警报(“!”))。
知道为什么..?
更新:我试过把这个而不是错误:
error: function (jqXHR, textStatus, errorThrown) {
alert(jqXHR);
alert(textStatus);
alert(errorThrown);
}
我在警报中得到的是:
[object XMLHttpRequest] 错误未定义
我也尝试过 jqXHR.Status,它在警报中给了我 404。