Minervaz Mine Minervaz Mine - 3 years ago 130
HTML Question

why the data not loaded in the table when the page in the print dialog

i have a problem here
i make a page that have function for print page that contain of dynamic table. the print function method is open the page html that contain the dynamic table in the new tab then open the print dialog. the process going well but when i add the ajax call for displaying the data in the dynamic table. the data not displayed at the table in the print dialog..but when i cancel the print dialog and the page that must be printed show off the data is displaying there...

how to fix it.

this the picture of the page
enter image description here

enter image description here

i use this code for print that

function myFunction() {



Answer Source

You didnt provided yet the code of your generator, so I simply explain you why its not working and what you can do.

A good reference for window Mozilla Window Open

You can read there more details about possible functions and more. Your problem is, with:


Directly after opening the file you call the print function, at this moment your script and ajax request don´t have finished yet. Thats why it just shows you the current state with the predefined html and css code.

So what you have to do is simply call print after it has finished. There are tons of ways to achieve this.

The simplest way would it to open it like this:


Inside your SPL.html you stack your js script inside:

$(document).ready() {
 //Your Generator

This little piece keeps safe that all dependencys (external scripts and dom elements) are created before your generator runs and it gives us the possibility for the next function:


This one is a version of the globalEventHandler window.onload. It basicly ,if you read the documentation, fires after everything is loaded, including images, frames, objects and so on. And the tricky part also after document.ready, this makes it sure that our generator is finished before we run the print command.

I hope this helps, If you really want to stick the print command inside your first page I can give you an example of this too. But it is not as bullet prove as this solution. Ah and if you want to stick with @Saurabh solution you have to use allow-modals for your Iframe, if not it wouldn´t be possible to print. Is also mentioned in the official documentation.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download