$('#submit_btn').click(function(){
var rows = [];
$('#box-table-a tbody tr input[type=checkbox]:checked').each(function(i,v){
var tds = $(v).parents('tr').children('td');
rows.push({
'name': tds.eq(1).find('select').val(),
'units': tds.eq(2).text(),
'calories': tds.eq(3).text(),
'sugar': tds.eq(4).text()
});
});
rows = JSON.stringify(rows); // submit this using $.post(...)
$.post('classes/process.php', {'rows': rows}, function(data){
console.log(data);
});
});
kirim rows
menggunakan $.post() dan kemudian, di sisi server, Anda dapat mengonversi kembali menjadi array menggunakan json_decode()
;
Contoh keluaran:
[{"nama":"Air","unit":"1","kalori":"2","gula":"3"},{"nama":"Makanan","unit":"4 ","kalori":"5","gula":"6"}]
Demo:
http://jsfiddle.net/cp6ne/84/