Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [inne][jQuery] AJAX - brak odpowiedzi.
oomaster
post
Post #1





Grupa: Zarejestrowani
Postów: 305
Pomógł: 3
Dołączył: 4.08.2006
Skąd: GDA

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


Witam,

Siedzę od kilku bitych godzin i nie mogę znaleźć błędu. Firebug też nie wywala błędów ?!

Oczywiście wcześniej wszelkie biblioteki są dołączone. Walidacja formularzy działa z tym ,że po wysłaniu zamiast treści jest pusta strona?!
  1. <div id="contact_form">
  2. <form name="contact" method="post" action="">
  3. <label for="name" id="name_label"><b>Imię:</b></label><label class="error" for="name" id="name_error">Wpisz swoje imię.</label><br/>
  4. <input type="text" name="name" id="name" size="30" value="" class="text-input" />
  5. <br/>
  6. <label for="email" id="email_label"><b>Adres E-mail:</b></label><label class="error" for="email" id="email_error">Wpisz swój adres e-mail.</label><br/>
  7. <input type="text" name="email" id="email" size="30" value="" class="text-input" />
  8. <br/>
  9. <label for="phone" id="phone_label"><b>Zapytanie:</b></label><label class="error" for="phone" id="phone_error">Wpisz treść zapytania.</label><br/>
  10. <textarea name="phone" id="phone" rows="7" cols="13" class="imp"></textarea>
  11. <br/>
  12. <input type="submit" name="submit" class="button" id="submit_btn" value="Wyślij" />
  13. </form></div>

[JAVASCRIPT] pobierz, plaintext
  1. $(function() {
  2. $('.error').hide();
  3.  
  4. $(".button").click(function() {
  5. // validate and process form
  6. // first hide any error messages
  7. $('.error').hide();
  8.  
  9. var name = $("input#name").val();
  10. if (name == "") {
  11. $("label#name_error").show();
  12. $("input#name").focus();
  13. return false;
  14. }
  15. var email = $("input#email").val();
  16. if (email == "") {
  17. $("label#email_error").show();
  18. $("input#email").focus();
  19. return false;
  20. }
  21. var phone = $("textarea#phone").val();
  22. if (phone == "") {
  23. $("label#phone_error").show();
  24. $("textarea#phone").focus();
  25. return false;
  26. }
  27.  
  28. var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone;
  29. //alert (dataString);return false;
  30.  
  31. $.ajax({
  32. type: "POST",
  33. url: "process.php",
  34. data: dataString,
  35. success: function() {
  36. $('#contact_form').html("<div id='message'></div>");
  37. $('#message').html("<b>Wiadomość została wysłana.</b>")
  38. .append("<p>dziękujemy.</p>")
  39. .hide()
  40. }
  41. });
  42. return false;
  43. });
  44. });
  45. runOnLoad(function(){
  46. $("input#name").select().focus();
  47. });
[JAVASCRIPT] pobierz, plaintext
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: 25.08.2025 - 11:51