I am an absolute newbie to jquery. So this might be a very basic question, please bear with me.
I have defined a jQuery function, which creates a 2-d array.
<script type="text/javascript">
$(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!');
}
})
});
</script>
<body>
<table>
<thead>
</thead>
</table>
</body>
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 $('#myTestDiv').text(datatable[2][0]); is printing expected output.
How to achieve this?
Thanks a lot.