$('#tablePaySave').click(function() {
var test = [];
var month = 1;
var year = $('#tablePayYear').val();
$('.table').find(':input').each(function(i, input) {
var cell = {};
cell['id'] = input.id;
cell['type'] = $(this).data('type');
cell['value'] = input.value;
cell['month'] = month;
month++;
if (month > 12) {
month = 1;
};
cell['year'] = year;
test.push(cell);
});
$.ajax({
type: "POST",
url: "/accounting/save",
data: {test: test},
dataType: "json",
success: function(data) {
console.log('success');
},
error: function(data) {
console.log('error');
}
});
});
var cell = {};
...
data: {test: test},