c# - jquery发布错误500

标签 c# javascript

我使用了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 
}  

看看this post

关于c# - jquery发布错误500,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23910874/

相关文章:

Javascript 正则表达式模式将多个字符串(AND、OR)与单个字符串匹配

javascript - Sequelize findAndCountAll 分页问题

c# - 使用母版页清除 ASP.NET 页面中的所有控件

c# - FindLast 在 IEnumerable 上

c# - 进度条在 winform 中卡住

c# - 如何合并两个 lambda Expression<Func>

c# - 等待IO的可重用测试代码

javascript - 简单的 Array.prototype 给出了 TypeError

javascript - Bokeh 服务器获取鼠标位置

javascript - Google map API v3 使叠加层显示在单独的 DOM 元素街景上