Triggering Javascript after AJAX

I have a page starting out with:

<div id="ajaxTarget"> </div>

After an AJAX call, the innerhtml is updated to:

<div id="ajaxTarget">     <div id="newDiv" /> <div>

where after the new content is loaded, I want to run

$('newDiv').fade({ duration: 2.0, from: 1, to: 0 });

I can't figure out how to set this up. Code examples or links to documentation would be nice... :slight_smile:

see this creencast:

there ryan Bates shows how to use javascript after an ajax call and more. maybe it could help you.

I'm an idiot. A simple :onsuccess callback was all I needed.

But, on the upside, at the same time I figured out how insert javascript to be run after a "fake ajax file upload by redirect to iframe hack".