这让我很困惑——我不知道问题出在哪里!
此调用始终返回 500 错误:
询问:
$('body').on('click', '.day', function () {
// a suspect day has been clicked
if (confirm('Re-index documents received on this day?')) {
// re-index
var day = $(this).find('.day_number').text();
var year = parseInt($('#hidYear').val());
var month = parseInt($('#hidMonth').val());
$.ajax({
type: "POST",
url: "ajax.asmx/ReIndexDay",
data: JSON.stringify( { Month: month, Year: year, Day: day } ),
contentType: "application/xml; charset=utf-8",
dataType: "xml",
success: function (data) {
var calendarHTML = $(data).find(':first').text();
// update hidden fields and calendar
$('#hidYear').val(year);
$('#hidMonth').val(month);
$('#divContent').html(calendarHTML);
},
error: function (msg) {
alert("Failed: " + msg.status + ": " + msg.statusText);
}
});
}
});
C#
[WebMethod(Description = "Re-index the day and return HTML of a calendar table for the month")]
[ScriptMethod(ResponseFormat = ResponseFormat.Xml)]
public string ReIndexDay(int Day, int Month, int Year)
{
Diagnostic.ReIndex(Day, Month, Year);
return GetIndexCalendarHTML(Month, Year);
}
我现在被卡住了,所以所有建议都表示赞赏!
[编辑]
我从浏览器中得到了这个——不确定它是否准确,因为它可能不会复制同样的东西:
System.InvalidOperationException:请求格式无效:application/xml;字符集=UTF-8。在 System.Web.Services.Protocols.HttpServerProtocol.ReadParameters() 在 System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
[/编辑]