Welcome Guest, Not a member yet? Register   Sign In
Ajax Contact Form submit bug
#1

[eluser]guynamedkeith[/eluser]
Hello, I am in major need of some help. I am not very good with javascript and completely stuck on the below issue.

Goal: A codeigniter contact form sent through ajax that is validated using codeigniters validation and returns the proper view on failure or success, replacing DIV#contact-form with the new view.

Problem: My form submits fine through ajax, validates with codeigniter, and replaces DIV#content with the new form that has validation errors. If you now click submit again on the form currently filled with errors the form submits through http and does a full page refresh.

Notes: I am using codeigniter 1.7.2 and mootools 1.2 with mootools more.

Live example: http://keithloy.me/index.php/contact/index

Source: My dropbox

All relevant code is posted below:

mootools form send
Code:
 
window.addEvent('domready', function() {
    // You can skip the following two lines of code. We need them to make sure demos
    // are runnable on MooTools demos web page.
   
    // if (!window.demo_path) window.demo_path = '';
    // var demo_path = window.demo_path;
    // --
 
    var myForm = $('myForm');
   
    myForm.addEvent('submit', function(e) {
        //Prevents the default submit event from loading a new page.
        e.stop();
        //Empty the log and show the spinning indicator.
        var log = $('contact-form').addClass('ajax-loading');
        //Set the options of the form's Request handler.
        //("this" refers to the $('myForm') element).
        this.set('send', {onComplete: function(response) {
            log.removeClass('ajax-loading');
            log.empty();
            log.set('html', response);
        }});
        // send the form.
        this.send();
    });
});
 


Messages In This Thread
Ajax Contact Form submit bug - by El Forum - 06-25-2010, 12:45 AM
Ajax Contact Form submit bug - by El Forum - 06-25-2010, 12:45 AM
Ajax Contact Form submit bug - by El Forum - 06-25-2010, 01:22 AM



Theme © iAndrew 2016 - Forum software by © MyBB