【发布时间】:2014-11-14 12:12:37
【问题描述】:
我收到了一个 JSON 响应,其中包含来自此 Ajax 的对象列表(带有 ID、名称等):
$.ajax({
url: _this.attr('action'),
data: _this.serialize(),
dataType: "json",
success: function(json_data) {
alert('success!');
alert(JSON.stringify(json_data));
},
error: function(data) {
alert('error!');
}
});
现在我需要在视图中将这些信息显示为表格,类似于:
%table
%thead
%tr
%th= "ID"
%th= "Name"
%tbody
- @response.each do |resp|
%tr
%td= resp.id
%td= resp.name
我该怎么做?
【问题讨论】:
标签: jquery ruby-on-rails ajax json