I've been poking around with the debugger. For reference, here's the code:
var $form = $('form.roll');
url = $form.attr('action');
var $report = $('#report');
$.ajax({
url: url,
data: $form.serialize(),
dataType: 'html',
success: function (html, textStatus) {
$report
.html($('#report', html).html())
.css({
opacity: 1.0
});
style_preview_table();
}
The html variable passed into the success function contains the entire
page, including the javascript. I tried doing:
$report.html(html)
But the parts of the page that were not the results (i.e. #report) all
were duplicated (the page was displayed within the page). But even
there, the javascript wasn't included in the page, even though is was
in the html variable.
$('#report', html).html() contained just the html, without the
javascript. What I need is some way to get both the javascript and the
html of $('#report') and then pass that into $report.html(). Are there
javascript or jQuery methods that will allow me to do that?
Alternatively I could extract the javascript from the html variable
passed into the success function. But then how would I make that part
of $report.html()?