Page 1 of 1

Mootools AJAX form issue

Posted: Tue Mar 24, 2009 3:56 pm
by jugglerandrew
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:

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> 
 
Thanks!
- Andrew

Re: Mootools AJAX form issue

Posted: Tue Mar 24, 2009 4:24 pm
by kaszu
Add following code and see if there is anything outputed on submit.

Code: Select all

window.onerror = function (e) {
    alert(e);
};
I don't see what could cause this code to fail and why bringing form up the dom it would work.

Re: Mootools AJAX form issue

Posted: Tue Mar 24, 2009 5:19 pm
by jugglerandrew
kaszu wrote:Add following code and see if there is anything outputed on submit.

Code: Select all

window.onerror = function (e) {
    alert(e);
};
I don't see what could cause this code to fail and why bringing form up the dom it would work.
I added the code, but the problem continues. No alert was sent, so it seems like the event listener is completely ignoring my onsubmit event. :?

- Andrew