2016-04-29 4 views
0

こんにちは私は、ユーザーが提出をクリックすると、ページ上のフォームからキー/値のペアを取得するコードを取得しようとしています。私は周りを探してきたとメソッドの束を試してみましたが、のようなエラーを得続ける:JクエリーAJAXはフォーム情報を取得しますか?

キャッチされない例外TypeError:演算子「に」を使用することはできませんが、成功には「6」を検索する

マイコード:

<form action="./blah" id="thisform"> 
    <fieldset> 
     <legend>Place a Reservation</legend> 
     <label for="firstName">First name: </label> 
     <input id="firstName" type="text" placeholder="first name" autofocus="autofocus" 
     required="true" pattern="[a-z,A-Z]{8}"/><br/><br/> 

     <label for="lastName">Last name: </label> 
     <input id="lastName" type="text" placeholder="last name" 
     required="true" pattern="[a-z,A-Z]{1, 10}"/><br/><br/> 



     <label for="Phone">Phone number: </label> 
     <input id="Phone" type="phone-number" placeholder="(000)-000-0000" maxlength="10" minlength="10" 
     required="true" /><br/><br/> 

     <label for="Party">For how many people? </label> 
     <input id="Party" type="number" placeholder="#" min="1" max="12" value="1" 
     required="true"/><br/><br/> 

     <label for="date-of">Date of reservation </label> 
     <input id="date-of" type="date" placeholder="date of reservation" min="2016-01-01" 
     max="2016-12-30" value=""/><br/><br/> 

     <label for="Time-of">Time (24hr) </label> 
     <input id="Time-of" type="text" placeholder="00:00 " maxlength="20" /><br/><br/> 
     <input id="submit" type="submit" value="Submit"/> 
     <input type="reset" value="Reset"/> 



    </fieldset> 
    </form> 

、その後、スクリプトは

<script> 
    /*<![CDATA[*/ 
    $(document).ready(function() { 

     var submit = document.getElementById("submit") 

    submit.onclick = function(){ 
     $.get("reserve.html", function(key, value){ 
$.each(value, function(key, value){ 
    console.log(key, value); 
}); 
}); 
}; 


    }); 
    /*]]>*/ 
</script> 

私はかなり失われたと私は私のコードは方法でオフになって知っている、すべてのヘルプは大歓迎です!

おかげで(これも私の最初の名前入力は、私が入ると、なぜイムわからないものを受け付けていません)!

答えて

0

これは簡単です。このように$('form').serialize()を使用してください:

$.get('reserve.html?'+$(form).serialize()); 
関連する問題