Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [AJAX][PHP]Problem z wysłaniem danych formularza bez przeładowania
Forum PHP.pl > Forum > Przedszkole
Ulysess
witam mam taki o to skrypt:

  1. <script type="text/javascript">
  2. function SendRequest() {
  3. var req = mint.Request();
  4.  
  5. req.OnSuccess = function() {
  6. $("response").innerHTML = this.responseText;
  7. }
  8.  
  9. req.SendForm("ajax_form");
  10. req.resetForm = true;
  11. }
  12.  
  13. <script type="text/javascript">
  14. function refresh() {
  15. var req = mint.Request();
  16. req.OnSuccess = function () { document.getElementById("ajax_gospoda").innerHTML = this.responseText;},
  17. req.OnError = function () {document.getElementById("ajax_gospoda").innerHTML = "Wystąpił błąd !!! <br/>" + this.responseText + "<br/>" + req.xmlHttpRequest.statusText ;}
  18. req.Send ("ajax/gospoda_zawartosc.php<?php echo $link;?>");
  19. }
  20. var ginter=setInterval(refresh, 20000);
  21.  
  22.  
  23. <div id="ajax_gospoda" style="height: 450px; overflow: auto; bacground-color: #000000;"></div>
  24.  
  25. <div style="margin: 0px auto; text-align: center; width: 100%;">
  26. <form id="ajax_form" action="ajax/add_message.php<?php echo $link;?>" method="post">
  27. <div style="margin: 0px auto; text-align: center; margin-left: 90px;margin-right: 5px; float: left;">
  28. <input class="main" style="width: 460px;" name="tresc" type="text" maxlength="255" />
  29. </div>
  30. </form>
  31. <div style="margin: 0px auto; text-align: center; margin-right: 5px; float: left;"><button class="main" onclick="SendRequest()">Wyślij</button></div>


problem polega na tym że gdy wciskam button wyślij dane wysyłają się bez przeładowania ale gdy wciskam enter przechodzi mi do strony ajax/add_message.php
co jest tego powodem ? :|

dodatkowo mam problem z sesjami

w pliku gospoda_zawartosc.php początek strony jest sprawdzany czy dane sesje istnieja i czy mają odpowiednie wartości problem polega na tym że musze i w tym pliku ustawiać start sesjon co powoduje wywalenie "Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at E:\VertrigoServ\www\new\ajax\gospoda_zawartosc.php:1) in E:\VertrigoServ\www\new\ajax\gospoda_zawartosc.php on line 2" jak ten problem rozwiązać o ile da się go w ogóle rozwiązać..
3lanc
Do pierwszego:
  1. <div style="margin: 0px auto; text-align: center; width: 100%;">
  2. <form id="ajax_form" action="ajax/add_message.php<?php echo $link;?>" method="post">
  3. <div style="margin: 0px auto; text-align: center; margin-left: 90px;margin-right: 5px; float: left;">
  4. <input class="main" style="width: 460px;" name="tresc" type="text" maxlength="255" />
  5. </div>
  6. </form>
  7. <!-- tak nie moze byc -->
  8. <!-- <div style="margin: 0px auto; text-align: center; margin-right: 5px; float: left;"><button class="main" onclick="SendRequest()">Wyślij</button></div> -->


Musi byc
  1. <div style="margin: 0px auto; text-align: center; width: 100%;">
  2. <form id="ajax_form" action="ajax/add_message.php<?php echo $link;?>" method="post">
  3. <div style="margin: 0px auto; text-align: center; margin-left: 90px;margin-right: 5px; float: left;">
  4. <input class="main" style="width: 460px;" name="tresc" type="text" maxlength="255" />
  5. </div>
  6. <input type="submi" value="Ostyluj to sobie">
  7. </form>


CSS do submita stylujesz:
  1. input[type="submit"]
  2. {
  3. /* jakis css */
  4. }


Do drugiego problemu rozwiązanie jest dość proste


na koncu
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.