2011-01-06 3 views
2

Я расчесываю jQuery validation plug-in with the jQuery Form Plugin, чтобы отправить форму через AJAX. Это прекрасно работает в Firefox & Chrome, но (как обычно) Internet Explorer испытывает боль. По причинам, которые ссылаются на меня, IE игнорирует ajaxSubmit, в результате он представляет форму в обычном режиме.jQuery ajaxSubmit игнорируется IE8

Я следовал документации по валидации подключаемого модуля при построении моего кода:

JS:

<script src="/js/jquery.validate.min.js" type="text/javascript"></script> 
<script src="/js/jquery.form.js" type="text/javascript"></script> 
<script type="text/javascript"> 
$(document).ready(function() { 
    var validator = $("#form_notify").validate({ 
     messages: { 
      email: { 
       required: 'Please insert your email address. Without your email address we will not be able to contact you!', 
       email:'Please enter a <b>valid</b> email address. Without a valid email address we will not be able to contact you!' 
      } 
     }, 
     errorLabelContainer: "#error", 
     success: "valid", 
     submitHandler: function(form) {$(form).ajaxSubmit();} 
    }); 
    $('#email').blur(function() { 
     if (validator.numberOfInvalids() > 0) { 
      $("#label").addClass("label_error"); 
      return false; 
     } 
     else {$("#label").removeClass("label_error");} 
    }); 
    $('#form_notify').submit(function() { 
     if (validator.numberOfInvalids() == 0) { 
      $(this).fadeOut('fast', function() {$('#thank-you').fadeIn();}); 
      return true; 
     } 
     return false; 
    }); 
}); 
</script> 

Форма HTML:

<form id="form_notify" class="cmxform" name="form_notify" action="optin.pl" method="get"> 
           <fieldset> 
            <div class="input"> 
             <label id="label" for="email">Email Address:</label> 
             <input type="text" id="email" name="email" value="" title="email address" class="{required:true, email:true}"/> 
             <div class="clearfix"></div> 
            </div> 
            <input type="hidden" name="key" value="sub-745-9.224;1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0;;subscribe-224.htm"> 
            <input type="hidden" name="followup" value="19"> 
            <input type="submit" name="submit" id="submit-button" value="Notify Me"> 
            <div id="error"></div> 
           </fieldset> 
          </form> 

я не могу понять, что заставляет IE действовать по-другому, любая помощь будет сильно оценен.

При необходимости я могу предоставить дополнительную информацию.

Заранее благодарен!

ответ

0

Попробуйте следующее:

$('#form_notify').submit(function(e) { 
    e.preventDefault(); 
    if (validator.numberOfInvalids() == 0) { 
     $(this).fadeOut('fast', function() {$('#thank-you').fadeIn();}); 
      return true; 
    } 
    return false; 
});