jQuery Ajax post を使用して要素の配列をコントローラー アクションに投稿するにはどうすればよいですか。
これは私がしようとしている方法ですが、私のコントローラーは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);
}
誰かが私に欠けているものを教えてくれますか?
ありがとう