mam przykładowy formularz:
{% for key,match in matches %} <http://december.com/html/4/element/form.html> <http://december.com/html/4/element/input.html type="text" name="firstname[]" id="firstname" '> <http://december.com/html/4/element/input.html type="text" name="lastname[]" id="lastname" '> </http://december.com/html/4/element/form.html> {% endfor %}
<script type="text/javascript"> $(document).ready(function(){ $("#submit").click(function(){ $.ajax({ url:"{{ path('costam') }}", type:"POST", data:{ firstname: $("#firstname").val(), lastname: $("#lastname").val(), }, .... </script>
Dane wyciągasz po id które w dokumecie może być jedno unikalne.
A czemu nie wsadzić tego do jednego formularza i wówczas go posłać po zserializowaniu → http://api.jquery.com/serialize/
Viking rozumiem a więc po klasie a nie po ID ...
a więc w formularzu ma być tak:
<http://december.com/html/4/element/input.html type="text" name="firstname[]" id="firstname" class="firstname">
data:{ firstname: $(".firstname").val(), lastname: $(".lastname").val(), },
Kombinujesz. Zrób jeden formularz, coś typu:
ok spróbuję z serializacją.
nie wiem jednak czy ja to robię dobrze:
<http://december.com/html/4/element/div.html class="form"> <http://december.com/html/4/element/div.html class="coupon_form"> {% for key,match in matches %} <http://december.com/html/4/element/input.html type="hidden" name="match_id[]" id="match_id" class="match_id" value="{{ match.match_id }}"> <http://december.com/html/4/element/div.html class="coupon_form_desc"> {{ match.description }} </http://december.com/html/4/element/div.html> <http://december.com/html/4/element/div.html class="coupon_form_host"> {{ match.host }} </http://december.com/html/4/element/div.html> <http://december.com/html/4/element/div.html class="coupon_form_host_type"> <http://december.com/html/4/element/input.html type="text" name="hostType[]" id="hostType" class="hostType" maxlength='1'> </http://december.com/html/4/element/div.html> <http://december.com/html/4/element/div.html class="coupon_form_dash">-</http://december.com/html/4/element/div.html> <http://december.com/html/4/element/div.html class="coupon_form_guest_type"> <http://december.com/html/4/element/input.html type="text" name="guestType[]" id="guestType" class="guestType" maxlength='1'> </http://december.com/html/4/element/div.html> <http://december.com/html/4/element/div.html class="coupon_form_guest"> {{ match.guest }} </http://december.com/html/4/element/div.html> <http://december.com/html/4/element/div.html class="coupon_form_term"> {{ match.term }} </http://december.com/html/4/element/div.html> {% endfor %} </http://december.com/html/4/element/div.html> <http://december.com/html/4/element/input.html id="submit" type="submit" value="Submit"> </http://december.com/html/4/element/div.html> <http://december.com/html/4/element/script.html type="text/javascript"> $(document).ready(function(){ $("#submit").click(function(){ $.ajax({ url:"{{ path('typerka_types') }}", type:"POST", data: $(".form").serialize(), dataType:"JSON", success:function(data){ console.log(data); alert(data); }, error: function() { console.log("Wystąpił błąd"); } }); }); }); </http://december.com/html/4/element/script.html>
A jaki błąd dokładnie rzuca Firebug?
a jednak działą
wielkie dzięki za pomoc.
Pozdrawiam
Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)