Не удалось загрузить ресурс: сервер ответил со статусом 500 (Internal Server Error) в функции Bind
Я пытаюсь отправить вызов с помощью ajax, но в Chrome возникает ошибка, но в firefox нет ошибки. Но все же он не может назвать метод. Я попытался записать мой звонок в firebug, но в Firebug нет запроса на вызов. Так что причина в ошибке не возникает.
Код Index.chshtml находится ниже
function onLoad(e) {
var grid = $(this).data("tGrid");
//bind to the context menu of the Grid header
event.preventDefault();
$(this).find(".t-grid-header").bind('contextmenu', function (e) {
//wait for the menu to be generated
setTimeout(function () {
// bind to the checkboxes change event. The context menu has ID in the format "GridName" + "_contextmenu"
$('#globalsearchgrid_contextMenu :checkbox').change(function () {
debugger;
var $checkbox = $(this);
// the checked state will determine if the column has been shown or hidden
var checked = $(this).is(":checked");
// get the index and the corresponding column from the Grid column collection
var columnIndex = $(this).data("field");
var request = "{'columnIndex':'" + columnIndex + "'value':'" + checked + "'}";
$.ajax({
type: "POST",
url: "../../GlobalSearch/SaveColumnInfo",
data: request,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) { },
error: function (xhr, status, error) {
alert(error.responseTextss);
}
});
});
});
});
}
Метод контроллера
public JsonResult SaveColumnInfo(string columnIndex, string value)
{
CookieHelper helper=new CookieHelper();
helper.UpdateCookie(int.Parse(columnIndex), value.ToString());
return Json("Success");
}
Ошибка в хроме
POST http://localhost:3577/GlobalSearch/SaveColumnInfo 500 (Internal Server Error)
jQuery.ajaxTransport.send
jQuery.extend.ajax
(anonymous function)
jQuery.event.handle
jQuery.event.add.elemData.handle.eventHandle
Ответы
Ответ 1
Код 500 обычно указывает на ошибку на сервере, а не на код вашего кода. Некоторые мысли
- Обратитесь к разработчику сервера за дополнительной информацией. Вы не можете получить больше информации напрямую.
- Проверьте свои аргументы в вызове (значения). Ищите все, что, по вашему мнению, может вызвать проблемы для процесса сервера. Процесс не должен умирать и должен возвращать вам лучший код, но там также происходят ошибки.
- Может быть прерывистым, например, если база данных сервера опускается. Возможно, стоит попробовать в другое время.