Setting variable from within AJAX call?
<p>Im sure its something simple, but i cant seem to set variable data from within an AJAX request..</p>

<p>My servlet returns an array of numbers;</p>

<pre><code>    int[] array = {1,2,4,5,3,5,3,5};

    response.setContentType("application/json");
    response.setCharacterEncoding("UTF-8");
    response.getWriter().write(new Gson().toJson(array));
</code></pre>

<p>The data is passed to jquery, where i am trying to store the json data as an jquery array;</p>

<pre><code>    var test2 = [];
    $.post("servlet", { info: data},
                function(data) {
                    alert(data); // this alerts what i want stored...
                    test2.push(3); // testing if i can add 3 to test FAILS
                });
    test2.push(9); //this works
    test2.push(9); //this works
    options.series[0].data = test2;
</code></pre>

<p>Why can't i push a number onto test from with the ajax call?</p>

<p>The final result i want is to set options.series[0].data equal to the array of data returned by the servlet</p>
