sending array as json to php script : returns empty array
<p>i'm trying to send a form inputs as array to a php script </p>

<pre><code>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/&lt;?php echo $profile_username; ?&gt;' , {data : jsondata }, function(){
    })
}
</code></pre>

<p>on the php script </p>

<pre><code>$data =  json_decode($_post['data']);
var_dump($data);
exit;
</code></pre>

<p>and here is the result </p>

<pre><code>array (size=0)
  empty
</code></pre>
