Javascript: Arrays
<p>For some reason my values are not being stored in the array:</p>

<pre><code>var req = new Array();
$.get('./ajax/get_cat_info.php?cid=' +cid, function(data, textStatus) {
    var count = 0;
    $.each(data, function(key, val) {
        $('#' + key).show();
        if(val == 1) {
            req[count] = key;
            count = count + 1;
            //var arLen=req.length;
            //alert('l: ' + arLen); // this works though
        }
    });
}, 'json');

var arLen=req.length;
alert('l: ' + arLen);
</code></pre>

<p>I get alerted "l: 0" at the end. If I uncomment the line alert in the IF statement, it alerts on each one, then still alerts 0.</p>
