Question

am trying to put together Jquery Validate with submitHandler and Jquery plugin AjaxForm. The code below does not give any error but it does not call the php file or it seems to die somewhere. Unfortunately with firebug I got no errors. Without using the submitHandler it works ok. All necessary files are loaded.

$('#form-ev').validate({    
  rules: {
    .....
  }, //end rules
  messages: {
    ......
  },
  submitHandler: function(form) {
    $('.loading').fadeIn('slow');
    var insertOptions = { 
      url:       '/js/ajax/add.php',
      type:      'post',
      dataType:  'json', 
      clearForm: true,
      success: function(html) {
        if (html==1) {
          $('.loading').fadeOut();
          $('.success').delay(1500).fadeIn('slow').delay(2000).fadeOut('slow');
        } else {
          $('.error').show('slow').delay(2000).hide('slow');
        }
      }
    };

    $('#form-ev').ajaxForm(insertOptions);  
  }
});  

Can someone please help me understand what I am doing wrong?

Was it helpful?

Solution

Have you tried replacing this line :

$('#form-ev').ajaxForm(insertOptions);

with :

$('#form-ev').ajaxSubmit(insertOptions);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top