フォームの検証に ajax を使用していますが、フォームが php の while ループにあり、リクエスト ajax が最初のフォームでのみ機能します。
私のコード:
アヤックス:
<script type="text/javascript">
$(document).ready(function() {
$('#form_entourage').on('submit', function() {
    var nom = $('#entourage_nom_1').val();
    var prenom = $('#entourage_prenom_1').val();
    if(nom == '' || prenom == '') {
        alert('Les champs doivent êtres remplis');
    } else {
        $.ajax({
            url: $(this).attr('action'),
            type: $(this).attr('method'),
            data: $(this).serialize(),
            dataType: 'json',
            success: function(json) {
                if(json.reponse == 'ok') {
                    alert('Tout est bon');
                } else {
                    alert(''+ json.reponse);
                }
            }
        });
    }
    return false;
});
});
</script>
PHP フォーム: 私の loop while と私の ajax は 1 つのフォームだけで動作します。例: 3 つのメンバーがある場合、ajax 検証は最初のメンバーでのみ機能し、2 番目のメンバーでは php 検証でリダイレクトしました。
        while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
       printf ("
              <h3>Membre ".$numero_membre."</h3>");
       $numero_membre = $numero_membre+1;
       printf ("
<form class='form-horizontal' id='form_entourage' method='post' action='modif/mod_entourage.php' style='height: 670px;'>
          <span class='span5 control-group'>
            <label for='entourage_nom_1'>Nom</label>
            <input class='span5' type='text' name='entourage_nom_1' value='".$row["nom"]."' >
            <input type='hidden' name='id_entourage' value='".$row["id_entourage"]."' >
          </span>
          <span class='span5 control-group'>
            <label for='entourage_prenom_1'>Prénom</label>
            <input class='span5' type='text' name='entourage_prenom_1' value='".$row["prenom"]."' >
          </span>
<span class='span5 control-group'>
<input type='submit' name='mod_entourage' id='mod_entourage' class='btn btn-primary pull-right' value='Modifier' /></span>
          </form>
          <div class='clear'></div>
");
    }
誰かが私を助けてくれますか?