I have a table with checkboxes, and I am posting it by clicking <a id='fecth_details'... as:
$('#fetch_details').click(function(e) {
e.preventDefault();
var data = { 'selected_sales[]' : []};
$("input[name='salesID[]']:checked").each(function() {
data['selected_sales[]'].push($(this).val());
});
$('#list_data').html('');
$.post('fetch_sales_details',data,function (data) { $('#list_data').html(data)});
});
I need to control it if it is empty or not. Basically testing like:
var data = ({ 'choices[]': ["Jon", "Susan"] });
alert(data);
if ($.isEmptyObject(data.choices))
{
alert('it is an empty object');
}
else
{
alert('auch! I am not empty');
}
But not working… I shouldn’t work if no checkbox is checked.
try