jQuery.post 함수를 사용하여 배열을 게시 할 수없는 것 같습니다. 500 내부 서버 오류 코드가 발생합니다.
이
실제의 jQuery 게시물 :function ChangeAllStatuses(statusId) {
var ids = [];
var i = 0;
var hiddenIds = $('[name|="serialIds"]');
hiddenIds.each(function() {
ids[i++] = $(this).val();
});
$.post(
ChangeAllStatusesURL,
{
serialIds: ids, //this is the array
statusId: statusId
},
function (data) {
if (data.indexOf('Error') == 0)
$('#message').html(data);
else
location.reload();
})
}
이는 POST 데이터 기대 컨트롤러 액션이다
[HttpPost]
public ActionResult ChangeAllStatuses(int[] serialIds, int statusId)
{
string result = service.ChangeAllStatuses(serialIds, statusId);
return Content(result);
}
500 서버 오류 서버 "이외의 아무것도 의미하지 않는다 오류". 서버에서이를 디버깅해야합니다. – Archer
@Archer, serialIds가 서버 null에 도달했으며 이유를 알 수 없습니다. ids 변수가 null이 아니므로이 변수를 사용하여 post 매개 변수를 설정하면 ids가 2 개의 int 값을 포함하는 배열입니다. –
개발자 도구를 사용하여 게시물을 디버깅 할 때 POST에 serialIds 매개 변수가 표시됩니다 (클라이언트가 서버에 값을 보내는 중임). –