在尝试调用WebMethod时,我的ajax函数不断收到错误500.
$.ajax({
type: "POST",
url: "BookingCalendar.aspx/TestFunction",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
alert(msg);
},
error: function () {
alert("Error");
}
});
[WebMethod]
public static string TestFunction()
{
return DateTime.Now.ToString();
}
答案 0 :(得分:0)
经过更多的研究后,我发现在.NET中默认禁用GET和POST。我将其添加到web.config文件中:
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
有关详细信息,请查看here。