【发布时间】:2015-04-13 21:09:17
【问题描述】:
我想通过 AJAX 从 jQuery 调用一个带有响应的 ASP.NET 函数。
我有文件 Controll.aspx,其中包含 javascript 代码。接下来我有/Services/ControllService.asmx,函数在哪里,我想从js调用。
js代码:
$(document).ready(function () {
$('#btn_start').on('click', function () {
$.ajax({
type: "POST",
url: "Services/ControllService.asmx/Start",
data: {},
dataType: "json",
async: true,
contentType: "application/json; charset=utf-8",
success: function (response) {
console.log(response);
},
error: function (err) {
alert("Error:" + err.toString());
}
});
});
});
但我仍然收到错误 500。
POST http://localhost:56000/Services/ControllService.asmx/Start 500 (Internal Server Error)
k.cors.a.crossDomain.send
n.extend.ajax
你有什么提示吗,我需要设置什么?在 Web.config 中?
非常感谢。
【问题讨论】:
-
你能发布你的C#方法
Start -
您应该在代码中捕获异常,这将为您提供更多信息。或者您可以从网络检查器分析响应正文,您将在其中看到生成的错误页面..