doniyor
doniyor

Reputation: 37876

How to render a List in playframework

i am wondering how i can render a List to template as an ajax callback arg.

i did this:

List<String> filteredTW = Twitt.filtertw(tagname);
return ok(filteredTW).as("text/plain");

but is says, i need to define ok(List) function on my own. is it true that Playframework doesnot offer this function?

i would be thanksful to any attemp to help..

EDIT: my ajax function is:

    $(function() {
    $('.filter').click(function() {
        var tagname = $(this).text();
    $('.post').remove();
    $.ajax({
            url: '/filter',
            type: 'POST',
            dataType: 'html',
            context: this,
            data: { tags: tagname },
        }).success(function(response) {
            alert(response);
        });
    });
})

thanks

Upvotes: 0

Views: 623

Answers (1)

Steven Luu
Steven Luu

Reputation: 1077

You might want to try return ok(play.libs.Json.toJson(filteredTW));

In this case, you can treat response as a regular javascript array.

for (i = 0; i < response.length; i++)
  alert(response[i]);

Upvotes: 1

Related Questions