I'm sure some wizard will tell me this is a classic example of "piece of cake"; in which case I bow and promise to listen In case I've struck granite rock, feel free to throw questions my way and I'll tell you if I've tried it or not.

I have a file, main.php (I know this is the JS-forum, bear with me). It outputs HTML and inline Javascript functions. When the user clicks on a graphical "tab", that tab is activated, and an ajax call is made to fetch.php with some specific parameters. Once the ajax request has completed, a given innerHTML container on the now active tab is filled with the stuff that fetch.php outputs.

So far so good.

The problem is that the stuff that fetch.php outputs is partial pure HTML and partial inline javascript. And this is where it gets tricky. If I declare an inline javascript function in the returned data, Firefox (and I suspect MSIE) refuses to understand that the function is there. It simply doesn't exist (!).

Using the Web Developer add-on for Firefox, there's an option to look at "Source code" and "Generated source code". The output from these two differ in that when I view the "Generated source code", I see the dynamically inserted javascript/HTML from fetch.php, whereas viewing "just" the source doesn't.

What did I do wrong? How do I get the browser to find/accept/activate the javascript code/functions that were inserted dynamically? I cannot put them in a .js file and include it, since they need to be dynamically created, and I cannot use eval() since that executes javascript "as is", in which a function will not be executed unless called.

I'm using Prototype 1.5.1, and haven't run into any other snags with the Ajax, forms, etc. than this :-(