[Ajax] aktualizacja stanu pobierania danych |
[Ajax] aktualizacja stanu pobierania danych |
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
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" Ma ktoś jakiś pomysł? Będę wdzięczny :-) |
|
|
Wersja Lo-Fi | Aktualny czas: 23.09.2024 - 21:02 |