2

jquery/ajaxのお問い合わせフォームが必要なこのウェブサイトで作業しています。 IE7(とおそらくIE6,8、おそらくは9)以外はすべてうまく動作しますが、それらのサポートは要求/期待/必要ではありませんでした。ここではライブバージョンです:いずれの場合でIE7でJquery/Ajaxフォームが動作しない

http://njutsu.net

が、ここではjQueryのコードです:

<!-- JS --> 
    <script type="text/javascript" src="scripts/jquery.js"></script> 
    <script> 
function valid_email(email) { 
    if (!(/^[A-Z0-9._%+-][email protected][A-Z0-9.-]+\.[A-Z]{2,4}$/i).test(email)) 
     return false; 

    return true; 
} 


$(function(){ 
$("#testclass").submit(function(){ 


if (!valid_email($('#email').val())) { 
    alert('Por favor escribe un email valido.'); 
    $('#email').focus(); 

    return false; 
} 

if ($('#nombre').val().length == 0) { 
    alert('Por favor escribe tu nombre.'); 
    $('#nombre').focus(); 

    return false; 
} 

if ($('#apellido').val().length == 0) { 
    alert('Por favor escribe tu apellido.'); 
    $('#apellido').focus(); 

    return false; 
} 

if ($('#edad').val().length == 0) { 
    alert('Por favor escribe tu edad.'); 
    $('#edad').focus(); 

    return false; 
} 

if ($('#telcel').val().length == 0) { 
    alert('Por favor escribe tu telefono o celular.'); 
    $('#telcel').focus(); 

    return false; 
} 

if ($('#razon').val().length == 0) { 
    alert('Por favor escribe la razon por la cual deseas tomar una clase de prueba.'); 
    $('#razon').focus(); 

    return false; 
} 






    $.ajax({url: "testclass.php", 
    datatype: 'html', 
    type:'POST', 
    data: { "email": $("input[type=text][name=email]").val(), 
      "nombre": $("input[type=text][name=nombre]").val(), 
      "apellido": $("input[type=text][name=apellido]").val(), 
      "edad": $("input[type=text][name=edad]").val(), 
      "telcel": $("input[type=text][name=telcel]").val(), 
      "razon": $("textarea#razon").val(), 
      }, 
    success: function (response,textstatus){ 
    $("#secondary div.col1-2").html("<h4 class='thanks'>Gracias por enviar tu solicitud, nos pondremos en contacto apenas leamos tu mensaje para acordar una fecha y hora para tu clase de prueba.</h4>"); 
    $("#secondary div.col1-2").hide(); 
    $("#secondary div.col1-2").fadeIn(2000); 
    } 
    }); 
    return false; 
}); 



}); 


</script> 

そして、ここでは、フォームのHTMLです:いずれの場合で

<form id="testclass" action="testclass.php" method="post"> 
      <div class="row"> 
       <label>Tu E-Mail</label> 
       <input id="email" name="email" class="text" type="text"> 
      </div> 
      <div class="halfrow left"> 
       <label>Tu Nombre</label> 
       <input id="nombre" name="nombre" class="text" type="text"> 
      </div> 
      <div class="halfrow"> 
       <label>Tu Apellido</label> 
       <input id="apellido" name="apellido" class="text" type="text"> 
      </div> 
      <div class="halfrow left"> 
       <label>Tu Edad</label> 
       <input id="edad" name="edad" class="text" type="text"> 
      </div> 
      <div class="halfrow"> 
       <label>Tu Teléfono o Celular</label> 
       <input id="telcel" name="telcel" class="text" type="text"> 
      </div> 
      <div class="row"> 
       <label>Razón por la cual deseas tomar clases de Ninjutsu Instintivo</label> 
       <textarea id="razon" name="razon" class="textarea" cols="" rows=""></textarea> 
      </div> 
      <div class="row"> 
       <h5><input class="button" type="submit" value="Quiero tomar una clase de prueba" /></h5> 
      </div> 
</form> 

、フォームの重要な部分が提出されたときにフォームに「記入」されていない場合は、/iefail.phpに移動して知ることができるPHPチェックがあります。

私はJqueryを初めて使い慣れているので、IEのブラウザーのIEファミリを知っている以外はIE7の非互換性の問題の背後にあるのはなぜか分かりません。すべての助けに感謝します。

P.S.私はチェックして、私はJavaScriptがIE7で有効になっている、ちょうどあなたが不思議だった場合に備えて。私はこれを指摘するつもりだった

data: { "email": $("input[type=text][name=email]").val(), 
     "nombre": $("input[type=text][name=nombre]").val(), 
     "apellido": $("input[type=text][name=apellido]").val(), 
     "edad": $("input[type=text][name=edad]").val(), 
     "telcel": $("input[type=text][name=telcel]").val(), 
     "razon": $("textarea#razon").val(), <-- here 
     }, 

答えて

4

それはIEが無残に失敗の原因となっているあなたのdataオブジェクトの末尾に余分なコンマで

を高く評価しています。また、データオブジェクトの名前と値のペアの名前を引用符で囲むのは正しいですか?
+0

すべてのヘルプ/ガイダンスは –

+0

私はそれが重要だとは思わない。それは、とにかく私は今それをテストしていると言った。 – karim79

+0

@Aaron - 確認済み - 問題ではありません。 – karim79

関連する問題