I have page with a print button. From this page I will print a reportpage by an AJAX call. I've made a reportpage and with jquery the page will be printed when I call that page directly in the browser. In this page I used:
$(document).ready(function () {
window.print();
});
So this works! But when I call the printpage with an AJAX call from the other page the print command won't fire:
$.ajax({
url:'pages/reportPage.php',
method:'POST',
data:{
id:id
},
error: function() {
alert('False!');
},
success:function(data){
//alert(data);
window.location.href = "index.php";
}
});
When I display the data (alert(data)), I see the code of the reportpage, so the reportpage is successfull called.
Does anybody knows why this won't work with an AJAX call?