我想知道如何将列表作为ajax回调参数呈现给模板。
我这样做了:
List<String> filteredTW = Twitt.filtertw(tagname);
return ok(filteredTW).as("text/plain");
但是我说,我需要自己定义ok(List)函数。Playframework真的不提供这个功能吗?
我将非常感谢任何愿意帮忙的人..
编辑:我的ajax函数是:
$(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);
});
});
})
谢谢
发布于 2012-07-03 20:31:52
您可能想尝试一下return ok(play.libs.Json.toJson(filteredTW));
在这种情况下,您可以将response
视为常规的javascript数组。
for (i = 0; i < response.length; i++)
alert(response[i]);
https://stackoverflow.com/questions/11318625
复制相似问题