当我尝试在同一页面中显示数据时,它工作正常,但我需要打开一个新窗口/选项卡,并将数据附加到该页面
$.ajax({
async : true,
type : 'GET',
cache : false,
url : 'rest/getReport',
data : 'startDate=' + fromDate + '&endDate=' + toDate,
datatype : 'json',
success : function (data) {
that.viewReport(data);
},
complete : function (data) {
$('#search-box').find('img.waiting').css('visibility', 'hidden');
}
});
这是成功时调用的方法
viewReport : function (data) {
var table;
window.open("details.htm");
table = $('#Report table');//#report is id of div in details.htm
if (data.length == 0) {
$('#Report .no-view-error').show();
return;
}
table.empty();
$.each(data, function (index, item) {
var row = '<tr id="tkNo-' + item.num + '">';
row += '<td>' +item.Date + '</td>';
row += '<td>' +item.Type + '</td>';
row += '<td>' +item.Num + '</td>';
row += '<td>' +item.receivedDate + '</td>';
row += '<td>' +item.doneBy + '</td>';
row += '<td>' +item.comments + '</td>';
row += '</tr>';
table.append(row);//appending rows to table in the new page
});
}
在我的jsp页面中,代码是
<div id="Report" class="showDetails">
<div class="error-box no-view-error">There are no details in this period.</div>
<table></table>
</div>