jQuery Ajax 게시물을 사용하여 컨트롤러 작업에 요소 배열을 게시하려면 어떻게해야합니까?ajax 게시물을 사용하여 MVC3 컨트롤러에 배열 게시
이것은 내가 시도하는 방법이지만, 내 컨트롤러는 null 어레이를 수신합니다.
function dipatchAllocations() {
// unSelected is an array of items of type int.
if (unSelected.length == 0) {
alert("Please select a line item to be dispatched.");
return;
}
debugger;
$.ajax({
type: 'POST',
url: '/Batch/SetToDispatch',
data: '{ "allocationId[]" : "[' + unSelected + ']","batchId" : "' + @Model.Id + '" }',
contentType: "application/json; charset=utf-8",
traditional: true,
success: updateView,
error: errorInSubscribing
});
};
는 그리고이
[HttpPost]
public ActionResult SetToDispatch(long[] allocationId,long batchId)
{
// Perform some action here
return View("_ReadyToDispatchItems",model);
}
누군가가 내가 놓친 거지 어떻게 저를 조언 할 수 내 컨트롤러
입니다. 당신은 단순히 쿼리 문자열로 컨트롤러에 데이터를 제공 할 수 있습니다
제거 피곤 되세요 "[]"allocationId – ankur
후'unSelected' 선언을 보여줄 수 있습니까? – testCoder