i'm trying to send a form inputs as array to a php script
function submit_form(){
var arr = [];
var key, val ;
$('#form input').each(function(){
key = $(this).attr('id');
val = $(this).val();
arr[key] = val;
})
alert(arr['username']); // check to see if array is not empty
var jsondata = JSON.stringify(arr);
$.post(base_url+'profile/edit_profile/<?php echo $profile_username; ?>' , {data : jsondata }, function(){
})
}
on the php script
$data = json_decode($_post['data']);
var_dump($data);
exit;
and here is the result
array (size=0)
empty
{data: ...}
into{"data": ...}
? – Waleed Khan Jul 21 '12 at 19:10