1
var labels = new Array();

<?php foreach($crud_data as $cd ) { ?>
  labels['<?php echo $cd['name'] ; ?>'] = '<?php echo $cd['label'] ; ?>';
<?php } ?>

$.post('url.php' , { labels:labels} );

labelsこのように配列を送信できないのはなぜですか? Firebug には何も表示されません。

私のconsole.log(labels)結果:

[]

avatar
"avatar"

email
"email"

id
"id"

name
"name"

password
"password"

このように配列にデータを入力すると

<?php foreach($crud_data as $cd ) { ?>
  labels.push('<?php echo $cd['label'] ; ?>');
<?php } ?>

$.post('url.php' , { labels:labels} );

それは正常に動作します!

4

2 に答える 2