Yes! you can send multiple details array.
We can encapsulate the data like this:
$.ajax({
type: "POST",
url: "/Emp/MasterDetails",
data: {'first_array':JSON.stringify(details1),
'second_array':JSON.stringify(details2),
'third_array':JSON.stringify(details3)},
contentType: "application/json; charset=utf-8",
dataType: "json",
traditional: true,
success: function (data) {
alert(data.massge + " record(s) inserted.");
}
});
Your first_array, second_array, and third_array should be "arrays" at the receiving end. If not you can make it into an array.
For example:
$("#btnAjax").click(function() {
var array1 = new Array();
$(".checkBoxList1:checked").each(function() {
array1.push($(this).val());
});
var array2 = new Array();
$(".checkBoxList2:checked").each(function() {
array2.push($(this).val());
});
var array3 = new Array();
$(".checkBoxList3:checked").each(function() {
array3.push($(this).val());
});
var Details = '{"first_array":["' + array1.join('","') + '"],"second_array":]"' + array2.join('","') + '"],"third_array":["' + array3.join('","') + '"]}';
//You can simply use this "Details" with data like this,
$.ajax({
type: "POST",
url: "/Emp/MasterDetails",
data: Details,
contentType: "application/json; charset=utf-8",
dataType: "json",
traditional: true,
success: function (data) {
alert(data.massge + " record(s) inserted.");
}
});
}