I've created a system that can generate an online form page and send it to a printer.
This system utilizes AJAX to extract data from an existing page and send it to a Java servlet. The servlet then constructs the HTML and sends it back, where it is displayed in a separate window.
However, the HTML generated in the separate window doesn't respond to events (like clicks) until it's refreshed. If I click the "Print" button on the page, nothing happens until I refresh, at which point my print dialog appears.
The AJAX call:
function printForm(warrants) {
$.ajax({
type: "GET",
dataType: "html",
url: "AjaxServlet",
data: {formType: 'printForm', warrants: warrants, headerValues: getHeaderValues()
},
success: function (data) {
var win = window.open();
win.document.write(data);
}
})
}
The generated HTML page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
...
</p>
</div>
</body>