我使用了JavaScript代码来调用C#类中的方法(代码中提供的方法)。当回发时我收到错误 500,我想知道如何修复此问题以便调用该方法。
JavaScript调用C#类方法
$.ajax({
type: "post",
url: "TestChapter.aspx/timeFinished",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {
//
}
});
C# 类 testchapter.aspx 中的方法:
[System.Web.Services.WebMethod]
public void timeFinished() {
// my code is here
}
最佳答案
在 C# 类 testchapter.aspx 中尝试此方法,它可能会起作用:
[System.Web.Services.WebMethod]
public static void timeFinished() {
// my code is here
}
关于c# - jquery发布错误500,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23910874/