I have a 'var' array with 21 attributes and it works fine. But one additional attribute is added to my array the method stops working. Array data passed into the MVC controller. Is it impossible to use more than 21 attributes in a var array?
This is my ajax code used to send data into controller.
var DailyStock = [];
for (var i = 0; i <= 45; i++) {
DailyStock.push(
{
"DatePeriod": CreateDate($("#currDate" + i + "").text()),
"JctLMS": $("#jctLMS" + i + "").val(),
"ConfLMS": $("#confLMS" + i + "").val(),
"FutLMS": $("#futLMS" + i + "").val(),
"ParclLMS": $("#parcelLMS" + i + "").val(),
"JctLIOC": $("#jctLIOC" + i + "").val(),
"ConfLIOC": $("#confLIOC" + i + "").val(),
"FutLIOC": $("#futLIOC" + i + "").val(),
"ParclLIOC": $("#parcelLIOC" + i + "").val(),
"JctIOE": $("#jctIOE" + i + "").val(),
"ConfIOE": $("#confIOE" + i + "").val(),
"FutIOE": $("#futIOE" + i + "").val(),
"ParclIOE": $("#parcelIOE" + i + "").val(),
"JctLMSL": $("#jctLMSL" + i + "").val(),
"ConfLMSL": $("#confLMSL" + i + "").val(),
"FutLMSL": $("#futLMSL" + i + "").val(),
"ParclLMSL": $("#parcelLMSL" + i + "").val(),
"BargeLMS": $("#bargeLMS" + i + "").val(),
"StockIHLMS": $("#stckinhandLMS" + i + "").val(),
"BargeLIOC": $("#bargeLIOC" + i + "").val(),
"StockIHLIOC": $("#stckinhandLIOC" + i + "").val(),
"BargeIOE": $("#bargeIOE" + i + "").val()
},
);
}
DailyStock = JSON.stringify({ 'DailyStock': DailyStock });
$.ajax({
contentType: 'application/json; charset=utf-8',
dataType: 'json',
type: 'POST',
url: '../Home/SetQuantity',
cache: false,
async: false,
data: DailyStock,
success: function (data) {
if (data.Success == true) {
alert('success');
}
else {
alert('Error');
}
},
});
C# controller Json Result Method
public JsonResult SetQuantity(List<DailyStock> DailyStock)
{
try
{
DBHandle DB = new DBHandle();
// DB.SetTable(DailyStock);
return Json(new { Success = true }, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
return Json(new { Success = false, ErrorMessage = ex.Message }, JsonRequestBehavior.AllowGet);
}
}
Class
public class DailyStock
{
public DateTime DatePeriod { get; set; }
public string JctLMS { get; set; }
public string ConfLMS { get; set; }
public string FutLMS { get; set; }
public string ParclLMS { get; set; }
public string JctLIOC { get; set; }
public string ConfLIOC { get; set; }
public string FutLIOC { get; set; }
public string ParclLIOC { get; set; }
public string JctIOE { get; set; }
public string ConfIOE { get; set; }
public string FutIOE { get; set; }
public string ParclIOE { get; set; }
public string JctLMSL { get; set; }
public string ConfLMSL { get; set; }
public string FutLMSL { get; set; }
public string ParclLMSL { get; set; }
public string BargeLMS { get; set; }
public string StockIHLMS { get; set; }
public string BargeLIOC { get; set; }
public string StockIHLIOC { get; set; }
public string BargeIOE { get; set; }
}