单击按钮时,我在页面加载后将一些数据传递给 .cs 文件。但是在调用 ajax 函数时出现了 500 Internal Server Error。
Ajax 函数,
$.ajax({
type: "POST",
url: "Home.aspx/getSelectedData",
data: data,
contentType: "application/json; charset=utf-8",
dataType: "json",
//async: true,
调用函数,
[WebMethod]
[ScriptMethod(UseHttpGet = true)]
public List<pageResult> getSelectedData(string search_value)
{}
我得到以下错误,
**POST http://localhost:4519/Home.aspx/getSelectedData 500 (Internal Server Error)**
请您参考如下方法:
像这样使用 .cs 文件,
[WebMethod]
public static List<pageResult> getSelectedData(string search_value)
{}
对于 aspx 中的 ajax 调用,您应该将方法定义为 Static,然后只有它会为您工作。
