0

私はこのようにフォームをロードしました:

$('#content').load('contacts/contact.php #content' );

そして、私のフォームのhtmlは次のとおりです。

<div id="content">
<div class="post">
    <h1 class="title">Nous contacter</h1>

    <div class="entry">

        <div id='form_wrap'>

            <form method="post" name="contactForm" id="contactForm">
                <p>hi,</p>
                <label for="sujet">Sujet: </label>
                <input type="text" name="sujet" value="" id="sujet" class="validate[required,custom[chaine]] text-input" data-prompt-position="topLeft:10"/>
                <label for="message">Message : </label>
                <textarea  name="message" value="Votre Message" id="message" class="validate[required] text-input" data-prompt-position="topLeft:20"></textarea>
                <p></p> 
                <label for="name">Nom: </label>
                <input type="text" name="name" value="" id="name" class="validate[required,custom[chaine]] text-input" data-prompt-position="topLeft:10"/>
                <label for="email">Email: </label>
                <input type="text" name="email" value="" id="email" class="validate[required,custom[email]] text-input" data-prompt-position="topLeft:10"/>
                <input type="submit" name ="env" id ="env" value="Envoyer" />
            </form>
        </div>
    </div>  
</div>

送信後にフォーム内の要素の値を取得したいのですが、やろうとしています:

$("#sujet").val()

しかし、うまくいきません!!!

それらを取得する方法(送信後)?

ありがとう

4

2 に答える 2

0

serialize()またはserializeArray()を使用してデータを設定できます。

$('#contactForm').submit(function() {
  $.ajax({ 
    type: "POST", 
    url: "actionContact.php", 
    data: $(this).serializeArray()
});

http://api.jquery.com/serialize/

http://api.jquery.com/serializeArray/

于 2013-08-15T23:10:46.000 に答える