Reputation: 683
I am calling below jquery method to export the table details into PDF. PDF file is created in the java class while it is called and available in the path C:\apache-tomcat-7.0.40\webapps\TestProj\PDFfiles and the JSP where im having this script is loacted at C:\apache-tomcat-7.0.40\webapps\TestProj\WEB-INF\jsp But window.open is not working. I can get the alert message of "PDF generation success ---"
Any idea? Please help.
function openPDF() {
$.post("generatePDF", {action : "get"}, function(data) {
if (data.returnStatus == "SUCCESS") {
alert("PDF generation success ---");
var win = window.open('', 'fullscreen=no');
win.location.href = '../../PDFfiles/TestPdf.pdf';
win.focus();
//window.open('../../PDFfiles/TestPdf.pdf', 'fullscreen=no');
}
}, 'json');
}
I have tried below snippet also but no use..
window.open('../../PDFfiles/ShopsListPdf.pdf', 'fullscreen=no');
Upvotes: 1
Views: 1625
Reputation: 5490
window.open
works only on user actions like click
but if there is a delay after that it will be blocked by browser. delay like you have made in ajax call
. So try to execute window.open
asap after click
Note: sometimes when ajax call come too fast due to cache or something, the window.open may work, it happens to me lot of time, specially when I was trying to make a facebook login here the link when I posted a question fb login popup block
Upvotes: 2