[jQuery] AJAX & Javascript content

[jQuery] AJAX & Javascript content


Hi there,
I'm developing a site which uses the jQuery AJAX module. I want to
load external content into a div box inside the website. So far, there
are no problems, but when I try to load external content, in this case
HTML and Javascript, only the external Javascript is loaded.
To solve this problem, I tried to eval the Javascript, but with no
success, this time the Javascript was not loaded into the div box.
Who has a solution for this problem?
For the information, the eval script:
-----------------------------
function parseScript(_source) {
    var source = _source;
    var scripts = new Array();
    // Strip out tags
    while(source.indexOf("<script") > -1 || source.indexOf("</script") >
-1) {
        var s = source.indexOf("<script");
        var s_e = source.indexOf(">", s);
        var e = source.indexOf("</script", s);
        var e_e = source.indexOf(">", e);
        // Add to scripts array
        scripts.push(source.substring(s_e+1, e));
        // Strip from source
        source = source.substring(0, s) + source.substring(e_e+1);
    }
    // Loop through every script collected and eval it
    for(var i=0; i<scripts.length; i++) {
        try {
            eval(scripts[i]);
        }
        catch(ex) {
            // do what you want here when a script fails
        }
    }
    // Return the cleaned source
    return source;
}
-----------------------------