Mam taki oto formularz w TWIG:
<form id="form"> <div class="coupon_form"> {% for key,match in matches %} <input type="hidden" name="match_id[]" id="match_id" class="match_id" value="{{ match.match_id }}"> <div class="coupon_form_desc"> {{ match.description }} </div> <div class="coupon_form_host"> {{ match.host }} </div> <div class="coupon_form_host_type"> <input type="text" name="hostType[]" id="hostType" class="hostType" maxlength='1'> </div> <div class="coupon_form_guest_type"> <input type="text" name="guestType[]" id="guestType" class="guestType" maxlength='1'> </div> <div class="coupon_form_guest"> {{ match.guest }} </div> <div class="coupon_form_term"> {{ match.term }} </div> {% endfor %} </div> <input type="submit" value="Wyślij"/> </form>
oraz taki kod jQuery:
<script type="text/javascript"> $(function(){ $("#form").submit(function(e){ var form=$(this); $.ajax({ url:"{{ path('typerka_types') }}", dataType:"JSON", type:"POST", data:form.serialize(), success:function(data){ console.log(data); }, error: function() { console.log("Wystąpił błąd"); } }); e.preventDefault(); }); }); </script>
Dlaczego po kliknięciu przycisku "Wyślij" dane nie znikają z formularza ?
Czego mi tutaj brakuję ? Będę wdzięczny za podpowiedź.