Skip to content Skip to sidebar Skip to footer

Passing An Array Of Integers From Javascript To A Controller Action Of List

I am using javascript code to postdata to a controller action coded in C#. I am getting a null value when attempting to pass an array of integers in javascript created as follows:

Solution 1:

Because MVC expects the data in QueryString pattern like this: answers=1&answers=2&answers=3

If you use jQuery to do AJAX, default is answers[]=1&answers[]=2&answers[]=3

You could try traditional option

$.ajax({
  //...traditional:true,
  //...
});

refer to https://api.jquery.com/jQuery.ajax/

Post a Comment for "Passing An Array Of Integers From Javascript To A Controller Action Of List"