Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JavaScript] Odświeżanie skryptu
miras
post 3.07.2012, 17:21:51
Post #1





Grupa: Zarejestrowani
Postów: 1 004
Pomógł: 9
Dołączył: 18.01.2011
Skąd: Siedlce

Ostrzeżenie: (30%)
XX---


Witam, mam następujący problem:

  1. var xmlhttp;
  2.  
  3. function showPart(str)
  4. {
  5. xmlhttp=GetXmlHttpObject();
  6. var url="getuser.php";
  7. url=url+"?part="+str;
  8. url=url+"&sid="+Math.random();
  9. xmlhttp.onreadystatechange=stateChanged;
  10. xmlhttp.open("GET",url,true);
  11. xmlhttp.send(null);
  12. }
  13.  
  14. function stateChanged()
  15. {
  16. if (xmlhttp.readyState==4)
  17. {
  18. document.getElementById("informacja").innerHTML=xmlhttp.responseText;
  19. }
  20. }
  21.  
  22. function GetXmlHttpObject()
  23. {
  24. if (window.XMLHttpRequest)
  25. {
  26. return new XMLHttpRequest();
  27. }
  28. return null;
  29. }
  30.  


ten kod odświeża mi plik getuser.php, tylko wtedy jak zmieni się wartość selecta, a ja potrzebuję przerobić to tak, żeby odświeżało się samo np. co 10sekund, da się to osiągnąć ?

Dzięki z góry!


--------------------
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
miras
post 3.07.2012, 21:57:18
Post #2





Grupa: Zarejestrowani
Postów: 1 004
Pomógł: 9
Dołączył: 18.01.2011
Skąd: Siedlce

Ostrzeżenie: (30%)
XX---


Ja wykombinowałem coś takiego:
  1.  
  2. var xmlhttp;
  3. var coo = document.getElementsByName("rekord");
  4. var co = co[0];
  5.  
  6. function showPart(str)
  7. {
  8. xmlhttp=GetXmlHttpObject();
  9. var url="getuser.php";
  10. url=url+"?part="+str;
  11. url=url+"&sid="+Math.random();
  12. xmlhttp.onreadystatechange=stateChanged;
  13. xmlhttp.open("GET",url,true);
  14. xmlhttp.send(null);
  15. }
  16.  
  17. function stateChanged()
  18. {
  19. if (xmlhttp.readyState==4)
  20. {
  21. document.getElementById("informacja").innerHTML=xmlhttp.responseText;
  22. }
  23. }
  24.  
  25. function GetXmlHttpObject()
  26. {
  27. if (window.XMLHttpRequest)
  28. {
  29. return new XMLHttpRequest();
  30. }
  31. return null;
  32. }
  33.  
  34. intervalID = window.setInterval(showPart(co.value), 500);


Nie robiłem tego 'na chama', żeby tylko pokazać, że coś robiłem i dostać gotowca, chociaż do tego bije, ale naprawdę się starałem..


--------------------
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: 14.08.2025 - 12:33