チェックボックスがチェックされている場合、2行ごとにすべての要素を取得し、それらをjson配列にして、ajaxで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+'}';
}
});
問題は、そのコードを使用して、php で配列を取得すると、次のようになることです。
array(1) {
[791]=>
string(501) "{field 1:2012-10-07,field 2:6777.00 }"
}
そのようなJSONの場合、どうすればそれを取得できますか:
array(1) {
[791]=>
[field 1]=>'2012-10-07',
[field 2]=>'6777.00'
}
困っている人を助けてくれてありがとう。