How to access a jQuery variable outside script?
<p>I am an absolute newbie to jquery. So this might be a very basic question, please bear with me.</p>

<p>I have defined a jQuery function, which creates a 2-d array.</p>

<pre><code>    &lt;script type="text/javascript"&gt;
        $(document).ready(function() {
            $.ajax({
                url: '/testdata.txt',
                dataType: 'text',
                success: function(data) {
                    var datatable = [];
                            // Populate datatable[]. This is a 2-d array.
                            $('#myTestDiv').text(datatable[2][0]);
                        },
                        error: function(){
                            alert('error!');
                        }
                    })
                });
    &lt;/script&gt;

&lt;body&gt;
    &lt;table&gt;
        &lt;thead&gt;
        &lt;/thead&gt;
    &lt;/table&gt;
&lt;/body&gt;
</code></pre>

<p>Now, I want to print the 2-d array, "datatable", in the HTML table, preferably with JSTL. But it appears that the "datatable" variable is not accessible outside . I know that the table is being populated correctly, the <code>$('#myTestDiv').text(datatable[2][0]);</code> is printing expected output. </p>

<p>How to achieve this? </p>

<p>Thanks a lot.</p>
