【发布时间】:2015-12-18 07:35:47
【问题描述】:
使用 jQuery 1.11.0。
当我进行 Ajax 调用时,错误是
发布http://localhost:9909/Admin/ReportsService.asmx?GetQuestionSets 500(内部服务器错误)
但我可以浏览 URL 并运行该方法而没有任何问题。
reports.js:
function getQuestionSets() {
$.ajax({
type: "POST",
url: "/Admin/ReportsService.asmx?GetQuestionSets",
data: "{ 'startDate': '" + $(".txtFromDate").val() + "', 'endDate': '" + $(".txtToDate").val() + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
console.log(msg.d);
},
Error: function (x, e) {
// On Error
}
});
}
ReportsService.asmx:
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
public class ReportsService : WebService
{
[WebMethod]
public void GetQuestionSets(string startDate, string endDate)
{
//code to get data.
}
}
web.config:
<webServices>
<protocols>
<add name="HttpGet" />
<add name="HttpPost" />
</protocols>
</webServices>
</system.web>
方法GetQuestionSets 的断点永远不会被命中。
我在这里错过了什么。
【问题讨论】:
标签: jquery asp.net ajax web-services