Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Połączenie dwóch skryptów
koxu1996
post
Post #1





Grupa: Zarejestrowani
Postów: 139
Pomógł: 3
Dołączył: 5.06.2011

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


Witam. Mam dwa skrypty które odświerzają divy. Jednak chce je połączyć w jeden plik.

plik 1: http://project-welcome.ugu.pl/test/ajax.js
plik 2: http://project-welcome.ugu.pl/test/ajax2.js

Skminiłem coś takiego:
  1. // Customise those settings
  2.  
  3. var seconds = 1;
  4. var divid = "timediv";
  5. var divid2 = "points";
  6. var url = "boo.php";
  7. var url2 = "boo2.php";
  8.  
  9. ////////////////////////////////
  10. //
  11. // Refreshing the DIV
  12. //
  13. ////////////////////////////////
  14.  
  15. function refreshdiv(){
  16.  
  17. // The XMLHttpRequest object
  18.  
  19. var xmlHttp;
  20. try{
  21. xmlHttp=new XMLHttpRequest(); // Firefox, Opera 8.0+, Safari
  22. }
  23. catch (e){
  24. try{
  25. xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer
  26. }
  27. catch (e){
  28. try{
  29. xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  30. }
  31. catch (e){
  32. alert("Your browser does not support AJAX.");
  33. return false;
  34. }
  35. }
  36. }
  37.  
  38. // Timestamp for preventing IE caching the GET request
  39.  
  40. fetch_unix_timestamp = function()
  41. {
  42. return parseInt(new Date().getTime().toString().substring(0, 10))
  43. }
  44.  
  45. var timestamp = fetch_unix_timestamp();
  46. var nocacheurl = url+"?t="+timestamp;
  47. var nocacheurl2 = url2+"?t="+timestamp;
  48. // The code...
  49.  
  50. xmlHttp.onreadystatechange=function(){
  51. if(xmlHttp.readyState==4){
  52. document.getElementById(divid).innerHTML=xmlHttp.responseText;
  53. document.getElementById(divid2).innerHTML=xmlHttp.responseText;
  54. setTimeout('refreshdiv()',seconds*1000);
  55. }
  56. }
  57. xmlHttp.open("GET",nocacheurl,true);
  58. xmlHttp.send(null);
  59. xmlHttp.open("GET",nocacheurl2,true);
  60. xmlHttp.send(null);
  61. }
  62.  
  63. // Start the refreshing process
  64.  
  65. var seconds;
  66. window.onload = function startrefresh(){
  67. setTimeout('refreshdiv()',seconds*1000);
  68. }


Jednak oba divy pokazują to samo, choć nie powinny. Pomoże ktoś?
Go to the top of the page
+Quote Post

Posty w temacie


Closed TopicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 20.08.2025 - 11:48