Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [Ajax] aktualizacja stanu pobierania danych
pawel_
post 18.03.2006, 11:38:15
Post #1





Grupa: Zarejestrowani
Postów: 42
Pomógł: 0
Dołączył: 12.12.2005

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


Witam smile.gif
napisałem sobie takie coś:
Kod
var http = getHTTPObject(); // Tworzymy instancję Ajax'a
var busy = false; // sprawdzamy zajętość aplikacji (czy aktualnie coś robi)
var url = 'getData.php?param='; // na jaki adres mają iść dane

function getHTTPObject() {
var xmlhttp;
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
  try {
      xmlhttp = new XMLHttpRequest();
  }
  catch (e) {
      xmlhttp = false;
  }
    }
    return xmlhttp;
}

function send(from, to) {
    var tmp = document.getElementById(from).value;
    http.open("GET", url + escape(tmp), true);
    http.onreadystatechange = send_to_form(to); http.send(null);
    busy = true;
    status = 'sending';
}

function send_to_form(name) {
    if (http.readyState == 4) { // jeśli wszystko się już załadowało
  if (http.responseText.indexOf('invalid') == -1) {
      var xmlDocument = http.responseXML;
      results = name.split(",");
      for(i in results) {
    name = results[i];
    alert(name);
    var tmp = xmlDocument.getElementsByTagName(name).item(0).firstChild.data;
    document.getElementById(name).value = tmp;    
      }
      document.getElementById(name).value = tmp;
      busy = false;
      status = 'done';
  }
    } else {
  if (http.readyState == 1)
      status = 'downloading';
  if (http.readyState == 2)
      status = 'downloaded';
  document.getElementById('status').value = status;
  setInterval(send_to_form(name),100);
    }
}


co chcę osiągnąć? chcę aby pokazywał mi w polu tekstowym "downloading", "downloaded", "done" .... ale przy aktualnym kodzie w konsoli debugowania w ff wyskakuje mi "too much recursion" sad.gif
Ma ktoś jakiś pomysł? Będę wdzięczny :-)
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: 24.04.2024 - 23:14