Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [Ajax][jQuery] Dlaczego po wysłaniu dane nie znikają z formularza ?
damianooo
post 4.07.2016, 19:26:07
Post #1





Grupa: Zarejestrowani
Postów: 493
Pomógł: 2
Dołączył: 15.07.2011
Skąd: Katowice

Ostrzeżenie: (0%)
-----


Witam,

Mam taki oto formularz w TWIG:

  1. <form id="form">
  2. <div class="coupon_form">
  3. {% for key,match in matches %}
  4. <input type="hidden" name="match_id[]" id="match_id" class="match_id" value="{{ match.match_id }}">
  5. <div class="coupon_form_desc">
  6. {{ match.description }}
  7. </div>
  8. <div class="coupon_form_host">
  9. {{ match.host }}
  10. </div>
  11. <div class="coupon_form_host_type">
  12. <input type="text" name="hostType[]" id="hostType" class="hostType" maxlength='1'>
  13. </div>
  14. <div class="coupon_form_dash">-</div>
  15. <div class="coupon_form_guest_type">
  16. <input type="text" name="guestType[]" id="guestType" class="guestType" maxlength='1'>
  17. </div>
  18. <div class="coupon_form_guest">
  19. {{ match.guest }}
  20. </div>
  21. <div class="coupon_form_term">
  22. {{ match.term }}
  23. </div>
  24. {% endfor %}
  25. </div>
  26. <input type="submit" value="Wyślij"/>
  27. </form>


oraz taki kod jQuery:

  1. <script type="text/javascript">
  2.  
  3. $(function(){
  4. $("#form").submit(function(e){
  5. var form=$(this);
  6. $.ajax({
  7. url:"{{ path('typerka_types') }}",
  8. dataType:"JSON",
  9. type:"POST",
  10. data:form.serialize(),
  11. success:function(data){
  12. console.log(data);
  13. },
  14. error: function() {
  15. console.log("Wystąpił błąd");
  16. }
  17. });
  18. e.preventDefault();
  19. });
  20. });
  21.  


Dlaczego po kliknięciu przycisku "Wyślij" dane nie znikają z formularza ?
Czego mi tutaj brakuję ? Będę wdzięczny za podpowiedź.
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 25.04.2024 - 15:52