Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> ajax i IE, problem z ajaxem w IE
linuxoida
post 5.05.2009, 15:36:06
Post #1





Grupa: Zarejestrowani
Postów: 65
Pomógł: 0
Dołączył: 11.09.2006
Skąd: wawa

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


Witam,

Mam takie pytanie ponieważ, jak wiecie IE wyświetla niektóre elementy lub i ich nie wyświetla. Mi o to, że Firefox, Opera oraz Safari wyświetlają zapytanie bez problemu, ale IE Jak zwykle ma to w d...
Czy ktoś może mi pomóc, ponieważ wyświetla błąd w linii 31 tego kodu:
  1. var http = false;
  2. if(window.XMLHttpRequest)
  3. {
  4. http = new XMLHttpRequest();
  5. }else if(window.ActiveXObject)
  6. {
  7. http = new ActiveXObject("Msxml2.XMLHTTP");
  8. if(!http)
  9. {
  10. http = new ActiveXObject("Microstft.XMLHTTP");
  11. }
  12. }
  13. function a()
  14. {
  15. http.open("GET","kalendarz.php?miesiac=Maj&rok=2009", true);
  16. http.onreadystatechange = calendarhtml;
  17. http.send(null);
  18. }
  19. function b(form)
  20. {
  21. var month = form.miesiac.options[form.miesiac.selectedIndex].text;
  22. http.open("GET","kalendarz.php?miesiac="+month+"&rok="+2009, true);
  23. http.onreadystatechange = calendarhtml;
  24. http.send(null);
  25. }
  26. function calendarhtml()
  27. {
  28. if(http.readyState == 4 && http.status==200)
  29. {
  30. document.getElementById('cal').innerHTML=http.responseText; //a dokładnie to tu
  31. }
  32. }


a kod html to:
  1. <div id="szukaj">
  2. <form action="kalendarz.php" method="get" id="form_connect">
  3. <label>Z:</label> <input type="text" name="from" value="" />
  4. <br />
  5. <br />
  6. <label>Do:</label> <input type="text" name="data" value="" />
  7. <br />
  8. <br />
  9. <input type="text" name="data" value="" />&nbsp;&nbsp;&nbsp;<a href="" onclick="a(); return false;">kalendarz</a><span id="cal"></span>
  10. <br />
  11. <input type="radio" name="radio" value="odjazd" /> odjazd <input type="radio" name="radio" value="przyjazd" /> przyjazd
  12. <br />
  13. <br />
  14. <br /><input type="submit" name="wykonaj" value="szukaj" />
  15. <br />
  16. </form>
  17. </div>


Z góry dzięki
Pozdrawiam

Ten post edytował linuxoida 5.05.2009, 15:37:42
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 3)
Lejto
post 5.05.2009, 16:40:50
Post #2





Grupa: Zarejestrowani
Postów: 1 385
Pomógł: 48
Dołączył: 23.05.2007

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


zobacz tak
[code]
document.getElementById("cal").innerHTML=http.responseText; //a dokładnie to tu
[code]


--------------------
Go to the top of the page
+Quote Post
paziek
post 6.05.2009, 12:17:14
Post #3





Grupa: Zarejestrowani
Postów: 207
Pomógł: 25
Dołączył: 16.11.2006

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


  1. <?php
  2. function xhttpRequest() {
  3.    var httpRequest;
  4.    if (window.XMLHttpRequest) { // Mozilla, Safari, ...
  5.        httpRequest = new XMLHttpRequest();
  6.    } else if (window.ActiveXObject) { // IE
  7.        var progIDs = [ 'Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.3.0', 'Msxml2.XMLHTTP', 'Microsoft.XMLHTTP' ];
  8.        for (var i = 0; i < progIDs.length; i++) {
  9.            try {
  10.                return new ActiveXObject(progIDs[i]);
  11.            }
  12.            catch (e) {
  13.            }
  14.        }
  15.    }
  16.    if (!httpRequest) {
  17.        return false;
  18.    }
  19.    return httpRequest;
  20. }
  21. ?>


Spróbuj takim.

Ten post edytował paziek 6.05.2009, 12:17:55
Go to the top of the page
+Quote Post
linuxoida
post 3.06.2009, 19:59:40
Post #4





Grupa: Zarejestrowani
Postów: 65
Pomógł: 0
Dołączył: 11.09.2006
Skąd: wawa

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


przykro mi ale nie działa mi nic:(

chodzi mi o to, że nie wiem dlaczego, ale alert przekazuje mi w IE a document.getElementById("calendar").innerHTML=http.responseText; nie chce
  1. function calendarhtml()
  2. {
  3. if(http.readyState == 4 && http.status==200)
  4. {
  5. document.getElementById("cal").innerHTML=http.responseText;
  6. alert("git");
  7. }
  8. }

wszytkie potrzebne ActiveXObject są dodane. Inne przeglądarki nie mają z tym najmniejszego problemu.

Ten post edytował linuxoida 3.06.2009, 20:04:52
Go to the top of the page
+Quote Post

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: 25.06.2025 - 00:30