views:

62

answers:

1

So I have two pages: index.php and contents.php. Index.php is doing an XMLHttpRequest to grab a table from contents.php... But when Index.php displays the response.Text, it doesn't run the Javascript originally on contents.php (because it's just displaying the contents, not running the script).

Trying to solve this problem, I simply put the code on index.php rather than contents.php, but for some reason the javascript wont find any elements displayed by the responseText.

(i.e document.getElementById('contents-table').innerHTML = 'asdf';

A: 
var content = 'asdf',
fragment = document.createRange().createContextualFragment(content),
parent = document.getElementById("contents-table");

parent.replaceChild(fragment, parent.firstElementChild);

considering that there is only one node in the parent node, this should work

w35l3y
The only problem is that this won't work with IE/Opera
Jon McIntosh