I'm using Scala Play Framework 2.1 for my website. I'd like to be able to pass an array or list to the client-side code for subsequent processing after the page is loaded. The list is essentially a bunch of things to later request from the server. My purpose is for the web page to be displaying data as it comes in.
The code below in a template works but it feels kludgy. Is there a better way to do this?
<script>
var items = [ @results.map{ res =>
"@res.item",
} ""]
</script>
Here's what I eventually want to do on the client-side:
for (var i = 0; i < items.length; i++)
{
var item = items[i]
jQuery.ajaxQueue({
url: "/dataJson",
data: {item : item}
}).done(function( data ) {
addColumn(data)
});
}