[jQuery] Running Javascript from Ajax Response
I am trying to write my first application, and am trying to use jquery
to help me along my travels.
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.
This works on firefox, however it does not work on anything else. So
really my question is:
How do i run javascript code from an ajax response?
<form action="ajax/forms.php" method="post" id="myform">
Title: <input type="text" name="title" />
<input type="submit" value="Submit" name="submit" />
</form>
<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>
In the above, i only get an alert saying "Javascript" in firefox. Any
other browser and it does not work.
Please help!