Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> AJAX i 400 Bad Request, Your browser sent a request that this server could not understand.
bor1904
post 8.07.2012, 11:57:36
Post #1





Grupa: Zarejestrowani
Postów: 131
Pomógł: 1
Dołączył: 15.10.2009
Skąd: gdańsk

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


Witam,
Chciałem wykorzystać odrobine AJAXA i już straciłem kilka godzin.

Jest formularz:
  1. <form onsubmit="return send()" name="contact_form" method="post" action="">
  2.  
  3. <label for="author">Imie i nazwisko:</label> <input type="text" id="name" name="name" />
  4. <div class="cleaner_h10"></div>
  5. <label for="email">Email:</label> <input type="text" id="email" name="email" />
  6. <div class="cleaner_h10"></div>
  7.  
  8. <label for="url">Telefon:</label> <input type="text" name="phone" id="url" />
  9. <div class="cleaner_h10"></div>
  10.  
  11. <label for="text">Wiadomość:</label> <textarea id="text" name="enquiry" rows="0" cols="0"></textarea>
  12. <div class="cleaner_h10"></div>
  13.  
  14. <input type="submit" value=" Wyślij"/>
  15.  
  16. </form>



Kod JS w head:

  1.  
  2. <script type="text/javascript">
  3. function send()
  4. {
  5.  
  6. var xmlhttp;
  7. if (window.XMLHttpRequest)
  8. {// code for IE7+, Firefox, Chrome, Opera, Safari
  9. xmlhttp=new XMLHttpRequest();
  10. }
  11. else
  12. {// code for IE6, IE5
  13. xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  14. }
  15.  
  16. xmlhttp.onreadystatechange=function()
  17. {
  18. if (xmlhttp.readyState==4 )
  19. {
  20. alert(xmlhttp.responseText);
  21.  
  22. }
  23. }
  24. xmlhttp.open("POST","test.php",false);
  25. xmlhttp.send();
  26. }
  27.  
  28.  


Skrypt test.php:
  1. <?php echo "fsdfs"; ?>





Po kliknięciu wyślij pojawia sie message boź z treścią pochodzącą z php, a po kliknięciu OK wyskakuje
"400 Bad Request
Your browser sent a request that this server could not understand. "



Co robie nie tak?

PS: z wielu tutków przeklejałem (w tym z W3Schools) i nic ....

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: 15.07.2025 - 17:31