Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [Ajax][jQuery] Dlaczego po wysłaniu dane nie znikają z formularza ?
damianooo
post
Post #1





Grupa: Zarejestrowani
Postów: 496
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
 
Start new topic
Odpowiedzi
damianooo
post
Post #2





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

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


hmm ... patrzę w Firefox w na zakładce Net klikając w wybranego requesta (POSTa) i na podzakładce (obok Headers i Post) Response i mam tak (wkleiłem tylko początek) :

  1. <!DOCTYPE html>
  2. <html class="no-js">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <title>Strona Główna | Typerka</title>
  7. <link rel="icon" type="image/png" href="/favicon.png">
  8. <meta name="description" content="">
  9. <meta name="viewport" content="width=device-width, initial-scale=1">
  10.  
  11. <link href="/bundles/mytyperka/css/styles.css" rel="stylesheet">
  12.  
  13. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
  14.  
  15. </head>
  16. <body class='opl' link="gray" vlink="gray" alink="gray">
  17.  
  18. <div id="content_01">
  19. ....

Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 30.12.2025 - 05:23