I have the following function that stores some data in ABC.PrintReport.reportData
.
I grab the data with AJAX requests. I then want to print the data in the new window that I open at the end of the getKeyData
function.
However, by the time the window opens, the AJAX requests have not returned the data, so I get errors about undefined properties. What is the solution to this?
getKeyData: function () {
for (var key in ABC.PrintReport.keyList) {
k = ABC.PrintReport.keyList[key].Report_Key;
ABC.PrintReport.reportData[k] = null;
(function(index) {
Ext.Ajax.request({
url: ABC.Core.servicePath + '/task/' + ABC.PrintReport.processInstanceID + '/report/' + ABC.PrintReport.keyList[key].Report_Key + '?portalID=' + ABC.Core.portalID,
success: function (response) {
ABC.PrintReport.reportData[index] = Ext.JSON.decode(response.responseText)[0];
}
});
})(k);
}
window.open(location.pathname + 'resources/printreport.html');
},