Problem w tym że jak wysyłam dane ajaxem to dostaję błąd 500 i w Firebugu w zakładce POST widzę że wraz z danymi wysłanymi idą puste dane z inputów, które powinny być niewidoczne dla skryptu.
Jak zakomentuję inputy, które nie powinny być widoczne to skrypt działa bez problemu i wysyła dane.
Co robię źle lub co jeszcze powinienem dopisać aby skrypt działał ?
HTML:
... {% else %} <form id="form"> <table class="tab_types"> {% for key,meet in meets %} <input type="hidden" name="meet_id[]" value="{{ meet.meet_id }}" /> <tr class="big_screen"> </tr> <tr class="small_screen"> <td class="team_name"> {{ meet.host }} </td> <td class="user_type"> <input type="text" class="tp" name="hostType[]" maxlength='1' /> </td> </tr> <tr class="small_screen"> <td class="team_name"> {{ meet.guest }} </td> <td class="user_type"> <input type="text" class="tp" name="guestType[]" maxlength='1' /> </td> </tr> {% endfor %} <tr> </tr> </table> </form> {% endif %} <script type="text/javascript"> $(function(){ $("#form").submit(function(e){ var form=$(this); $.ajax({ url:"{{ path('liga_typerow_types') }}", dataType:"JSON", type:"POST", data:form.serialize(), success:function(){ form.get(0).reset(); console.log("jest ok"); location.reload(); }, error: function() { console.log("Wystąpił błąd"); } }); e.preventDefault(); }); }); </script>
CSS:
/* USTAWIENIA DLA KAŻDEGO EKRANU */ table.tab_types { width: 100%; /*border-collapse: collapse;*/ } th { background: #333; color: white; font-weight: bold; } td, th { padding: 6px; border: 1px solid #ccc; text-align: center; } input[type="text"].tp { width: 10px; } /* USTAWIENIA DLA DUŻEGO EKRANU */ @media screen and (min-width:680px) { /* niewidoczne */ tr.small_screen{ display: none; } tr:nth-of-type(odd) { background: #eee; } } /* USTAWIENIA DLA MAŁEGO EKRANU */ @media screen and (max-width:680px) { /* niewidoczne */ tr.big_screen,td.term,td.desc, tr.col_name,td.gap,td.host, td.guest,td.type { display: none; } /* widoczne */ td.position{ width: 10%; } td.team_name{ text-align: left; width: 80%; } td.user_type{ width: 10%; } tr.small_screen:nth-of-type(3n) { background: #eee; } }
POST widoczny w Firebugu:
guestType[] 1 guestType[] guestType[] 1 guestType[] guestType[] 1 guestType[] guestType[] 1 guestType[] guestType[] 1 guestType[] guestType[] 1 guestType[] guestType[] 1 guestType[] guestType[] 1 guestType[] guestType[] 1 guestType[] guestType[] 1 guestType[] hostType[] 1 hostType[] hostType[] 1 hostType[] hostType[] 1 hostType[] hostType[] 1 hostType[] hostType[] 1 hostType[] hostType[] 1 hostType[] hostType[] 1 hostType[] hostType[] 1 hostType[] hostType[] 1 hostType[] hostType[] 1 hostType[] meet_id[] 1 meet_id[] 2 meet_id[] 3 meet_id[] 4 meet_id[] 5 meet_id[] 6 meet_id[] 7 meet_id[] 8 meet_id[] 9 meet_id[] 10