0
当我尝试显示在同一页面它工作正常的数据,但我需要打开一个新窗口/标签与附加到页面成功的Ajax调用,打开一个新的窗口,并追加数据
$.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');
}
});
数据
这是我的jsp页面呼吁成功
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
});
}
方法的代码是
<div id="Report" class="showDetails">
<div class="error-box no-view-error">There are no details in this period.</div>
<table></table>
</div>
你需要寻找在弹出的上下文中的'#报告table'。试试:'var popup = window.open(“details.htm”); table = $('#Report table',popup.document);' –