I want to take all elements from each 2 rows if a checkbox is chekced and make them in a json array and send it with ajax to the php.
$('input.pay').each(function(){
if($(this).is(':checked'))
{
row = $(this).parents('tr').attr('id').split('_');
type = row[0];
payID= row[1];
payJsonArr = '';
secondRow=', #'+type+'_'+payID+$('#rate_'+payID).attr('class');
$('#'+type+'_'+payID+secondRow).find('.take').each(function(){
if($(this).is('input') || $(this).is('select'))
payJsonArr += $(this).attr('name') + ':' + $(this).val()+',';
else if($(this).is('td') || $(this).is('span'))
payJsonArr += $(this).attr('name') +':'+ $(this).html().trim()+',';
});
payJsonArr += payJsonArr.substring(0, payJsonArr.length - 1);
payments[payID]= '{'+payJsonArr+'}';
}
});
The problem is that with that code i get the array in php i get the fallowing:
array(1) {
[791]=>
string(501) "{field 1:2012-10-07,field 2:6777.00 }"
}
How can i get it like it should if it was a JSON,like that :
array(1) {
[791]=>
[field 1]=>'2012-10-07',
[field 2]=>'6777.00'
}
If anybody can help i would appreciate it.Thank you all for helping those in need.