- $('task').addEvent('submit', function(event) {
- event.preventDefault();
- this.send({
- onSuccess: function(response) {
- alert(response);
- }
- });
- });
I was writing a script to submit a form via Ajax using Mootools 1.2. Had problems with the first version of script, until I found how to make it work. But I don't understand why the first version doesn't work and the second one works, they look like they do the same thing. Can someone shed the light on this?
In the following scripts, $('task') is the id of the form itself.
Here is the first version of the script, which doesn't send the form to the server, so it just doesn't work:
And here is the second version, which looks very similar, but does work perfectly:
- $('task').set('send', {
- onSuccess: function(response) {
- alert(response);
- }
- }).addEvent('submit', function(event){
- event.preventDefault();
- this.send();
- });
What is the difference between these two scripts?
I use Mozilla latest version on Ubuntu.
Thank you very much!


