Mootools AJAX form issue
Posted: Tue Mar 24, 2009 3:56 pm
Hello, I am trying to learn about Mootools, particularly form sending
asynchronously. However, when I press the submit button on my form, it
does not seem to stop the submit event and the form submits as usual
rather than asynchronously. However, when I place the form outside of the other
divs (wrapper, content, etc) it works fine! Any ideas would be
appreciated. Here is my relevant code:
Thanks!
- Andrew
asynchronously. However, when I press the submit button on my form, it
does not seem to stop the submit event and the form submits as usual
rather than asynchronously. However, when I place the form outside of the other
divs (wrapper, content, etc) it works fine! Any ideas would be
appreciated. Here is my relevant code:
Code: Select all
<head>
<script type="text/javascript">
window.addEvent('domready', function() {
$('addForm').addEvent('submit', function(e) {
//Prevents the default submit event from loading a new
page.
e.stop();
//Set the options of the form's Request handler.
//("this" refers to the $('myForm') element).
this.set('send', {onComplete: function(response) {
alert('tada');
}});
//Send the form.
this.send();
});
});
</script>
</head>
<body>
<div id="wrapper">
<div id="content">
<div id="lightbox1" class="lightbox">
<form id="addForm" method="get" action="bookmarks.php">
<input type="text" id="txtAddBookmarkUrl"
name="AddBookmarkUrl" />
<input type="submit" id="btnAddBookmark" name="Add"
value="Add" />
</form>
</div>
</div>
</div>
</body>
- Andrew