[jQuery] Execute JavaScript that is added to the page by AJAX?

[jQuery] Execute JavaScript that is added to the page by AJAX?


Basically, I have a JavaScript function (let's call the function
"displayDiv") that ends up writing a <div> to the page. If
"displayDiv" is called within a table cell, the <div> will be added
and displayed in that table cell. Now, what I'm trying to accomplish
is replicating this behaviour with an AJAX function (let's call the
function "callAJAX") that returns HTML containing "displayDiv" and
adding the code to a specific location in the page. I have tried
this, problem is that the JavaScript returned from "callAJAX" was not
executed.
I then did some research and tried a few things:
1. I tried parsing out the JavaScript (displayDiv) from the
returned HTML (callAJAX) and adding it to the <head> tag, which in
theory, should be executed. This approach did not work for me because
"displayDiv" writes a <div> to the page and from the <head> it would
not know where to write the <div>.
2. I have tried parsing out the JavaScript (displayDiv) from the
returned HTML (callAJAX) and executing it with EVAL() but this would
not work because the AJAX function would not know where to write the
<div> created within the "displayDiv" function.
I guess what I'm hoping for is some magical piece of code that would
tell the browser to parse the page again and execute the JavaScript
that was added to the page by the AJAX function.
============================
I am posting this on behalf of a friend who is to busy today :) If
anyone can tell me if this is even possible, and if so, where to go
next, that would be most excellent!
Many thanks,
- Jonny