Witam,
Mam taki oto formularz w TWIG:
<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 class="coupon_form_host"> {{ match.host }}
<div class="coupon_form_host_type"> <input type="text" name="hostType[]" id="hostType" class="hostType" maxlength='1'> <div class="coupon_form_dash">-
</div> <div class="coupon_form_guest_type"> <input type="text" name="guestType[]" id="guestType" class="guestType" maxlength='1'> <div class="coupon_form_guest"> {{ match.guest }}
<div class="coupon_form_term"> {{ match.term }}
{% endfor %}
<input type="submit" value="Wyślij"/>
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();
});
});
Dlaczego po kliknięciu przycisku "Wyślij" dane nie znikają z formularza ?
Czego mi tutaj brakuję ? Będę wdzięczny za podpowiedź.