Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

ajax ne vraca xmlhttp.responseText

[es] :: Javascript i AJAX :: ajax ne vraca xmlhttp.responseText

[ Pregleda: 614 | Odgovora: 0 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

ps090001d
Student

Član broj: 304438
Poruke: 1
*.dynamic.sbb.rs.



Profil

icon ajax ne vraca xmlhttp.responseText23.06.2012. u 16:02 - pre 144 meseci
function updateActiveClients(){
var xmlhttp;
if (window.XMLHttpRequest) // code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
else // code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.onreadystatechange = function(){
if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
document.getElementById("myDiv").innerHTML = xmlhttp.responseText; }
}

xmlhttp.open("GET", __dirname + "/clients.txt", true);
xmlhttp.send(null);
}


<div id="myDiv"><h3> Ovde treba da bude lista aktivnih klijenata </h3></div>
<button type="button" onclick="updateActiveClients()">Prikazi listu</button>

Prvo da naglasim da nisam neki ekspert :/ i ovaj problem mi je bas stvorio dosta muka...

E ovako, imam ovaj kod koji treba da refresh-uje myDiv element ove html stranice. Problem je sto se ne desava nista nakon pokretanja servera i klika na dugme, sve na stranici radi ok, sem ovoga. __dirname + "/clients.txt" je .txt fajl koji sadrzi imena svih aktivnih klijenata i koji se posebno update-uje. Sto je jos cudnije, kad mu dam neki ne-validan url klik na dugme mi vrati neki response koji mi duplira sve elemente na stranici, a ovako uopste ne vraca xmlhttp.responseText....

Hvala unapred
 
Odgovor na temu

[es] :: Javascript i AJAX :: ajax ne vraca xmlhttp.responseText

[ Pregleda: 614 | Odgovora: 0 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.