Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][HTML][AJAX] nie dziala w firefox
calebos
post
Post #1





Grupa: Zarejestrowani
Postów: 104
Pomógł: 3
Dołączył: 22.02.2008

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


Czesc

Czemu mi to nie chce smigac w Firefox 2/3?
Idea : onclick -> php -> mysql

W IE dziala ok
Poprawnie wyswietla alert z typem przegladarki w ff i ie.

  1. <?php /* sample4_1.php */ ?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  3. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml">
  5. <title>Sample 4_1</title>
  6. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  7. <link rel="stylesheet" type="text/css" href="style.css" />
  8. <script type="text/javascript" >
  9. //functions.js
  10. //Create a boolean variable to check for a valid Internet Explorer instance.
  11. var xmlhttp = false;
  12. //Check if we are using IE.
  13. try {
  14. //If the javascript version is greater than 5.
  15. xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  16. alert ("dont use IE5!!!");
  17.  
  18. } catch (e) {
  19. //If not, then use the older active x object.
  20. try {
  21. //If we are using IE.
  22. xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  23. alert ("dont use IE!!!");
  24. } catch (E) {
  25. //Else we must be using a non-IE browser.
  26. xmlhttp = false;
  27. }
  28. }
  29. //If we are using a non-IE browser, create a javascript instance of the object.
  30. if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
  31. xmlhttp = new XMLHttpRequest();
  32. alert ("Not IE!!!");
  33.  
  34. }
  35. //Function to run a word grabber script.
  36. function grabword (theelement){
  37. //If there is nothing in the box, run Ajax to populate it.
  38. if (document.getElementById(theelement).innerHTML.length == 0){
  39. //Change the background color.
  40. document.getElementById(theelement).style.background = "#CCCCCC";
  41. serverPage = "/wris/wordgrabber.php";
  42. var obj = document.getElementById(theelement);
  43. xmlhttp.open("POST", serverPage);
  44. xmlhttp.onreadystatechange = function() {
  45. if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
  46. obj.innerHTML = xmlhttp.responseText;
  47. }
  48. }
  49. xmlhttp.send(null);
  50. } else {
  51. //Change the background color.
  52. document.getElementById(theelement).style.background = "#FFFFFF";
  53. //If the box is already populated, clear it.
  54. document.getElementById(theelement).innerHTML = "";
  55. }
  56. }
  57. </head>
  58. <body>4
  59. <?php
  60. for ($i = 1; $i < 9; $i++)
  61. {
  62. ?>
  63.  
  64. <div class="dborder" id="dborder<?=$i?>" onclick="grabword(this.id)"></div>
  65. <br/>
  66. <?php }
  67. ?>
  68. </body>
  69. </html>
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 4)
nospor
post
Post #2





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Zeby pod IE ci nie dzialalo a ty nie wiesz czemu to rozumiem, ale pod FF...

Pod FF masz taki plugin FireBug. Zainstaluj go sobie a bedziesz wiedzial czemu ci nie dziala.

ps: skorzystaj z jakiegos liba do ajaxa bo takie reczne pisanie to sieczka
Go to the top of the page
+Quote Post
calebos
post
Post #3





Grupa: Zarejestrowani
Postów: 104
Pomógł: 3
Dołączył: 22.02.2008

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


OK.

Chcialem troche zalapac o co kaman bo nic nie czaje z javascriptu.
Jaki polecasz na start ?
Go to the top of the page
+Quote Post
nospor
post
Post #4





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




ja uzywam ostatnio: jQuery
http://jquery.com/

ale są jeszcze:
prototype
advAjax - tylko do ajaxa
wiele innych (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg)

Spróbuj na jQuery - ma dobrą dokumentację, masę pluginów (bedziesz mógł poźniej sobie rozszerzyc) i ogólnie jest fajny
Go to the top of the page
+Quote Post
calebos
post
Post #5





Grupa: Zarejestrowani
Postów: 104
Pomógł: 3
Dołączył: 22.02.2008

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


Wskazywaloby na blad jakiegos configa ale skoro w IE dziala poprawnie zassysanie tego php?

firebug :
  1. <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><html><head><title>400 Bad Request</title></head><body><h1>Bad Request</h1><p>Your browser sent a request that this server could not understand.<br /></p><hr><address>Apache/2.2.0 (Fedora) Server at 126.17.82.61 Port 80</address></body></html>



A jescze bug wskazuje na xmlhttp.send(null); w kodzie przy tym error 400.
Go to the top of the page
+Quote Post

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: 24.08.2025 - 20:04