I posted this yesterday to the MVC forum, but there has been no reply, and that forum looks like it's pretty stale, so I figured I'd post here.
I'm trying to pass a Javascript array to a JsonResult method, but continually receive 'null' values no matter if I change the type to list or an array. Interesting though, if I change the type to something outside of array or list (single variable), an exception is thrown for that method because it doesn't see any data being passed for that variable.
Firebug result of the post:
UPCs[] 12345678
UPCs[] 82314128
UPCs[] 23492382
I've also tried changing the list/array type from string, to int, but still receive a null result.
Javascript to send the data on click:
$("#removeUPCs").click(function () {
var upcArray = new Array();
upcArray[0] = 12345678;
upcArray[1] = 82314128;
upcArray[2] = 23492382;
$.post("/PO/DeleteUPCs", { UPCs: upcArray },
function (data) {
// success
}, "json");
});
[AcceptVerbs(HttpVerbs.Post)]
public virtual JsonResult DeleteUPCs(Int64[] UPCs) // have tried different types, lists, always null
{
string upcList = "";
foreach(Int64 upc in UPCs){
upcList += upc + ", ";
}
return Json(new { Result = upcList });
}
This post has been edited by W3bDev: 09 November 2010 - 10:46 AM

New Topic/Question
Reply



MultiQuote



|