To restate: > I have setup my application to work so all pages are loaded via ajax, > using anchor's as navigation. However on some pages that i return > using the AJAX i want to be able to run code.
So this code is the text of an AJAX response, correct? > <p> > <form action="ajax/forms.php" method="post" id="myform"> > Title: <input type="text" name="title" /> > <input type="submit" value="Submit" name="submit" /> > </form> > </p> > <script type="text/javascript"> > // attach handler to form's submit event > alert("Javascript"); > $('#myform').submit(function() { > // submit the form > alert("form submitted"); > // return false to prevent normal browser submit and page navigation > return false; > }); > </script> If so, I'd suggest pulling the script portion out of the response, and running it *after* inserting the HTML into the document. If you're simply inserting the text, *as is*, into the document, it's likely that the form ('#myform') is not yet available to be found by document.getElementById(). -- hj