Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JavaScript]This w JS / widocznosc zmiennej
topgun777
post
Post #1





Grupa: Zarejestrowani
Postów: 70
Pomógł: 0
Dołączył: 27.05.2008

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


Czesc
Mam taki problem ze nie wiem jak zrobic żeby funkcja Test poprawnie widziała zmienną thisUser.imie? Czym to moze być spowodowane ze jej nie widzi (wypisuje undefined) ? wiem ze po przeniesieniu jej wywolonia do funkcji anonimowej w request jest ok ale chce miec wywolanie Test w funkcji init po pobraniu informacji o userze. Czy mam ktos pomysł? nie chce tez zmieniać thisUser.imie na zmienną globalną imie chce zeby byla ona częścia obiektu User. Ponizej załączam kod:
CODE
function User(id){

var thisUser = this;
this.UID = id;
this.imie = "";
this.nazw = "";
this.login = "";
this.phone = "";
this.email = "";

this.init = function(){
thisUser.getUserInfo();

// thisUser.Test();
}

this.getUserInfo = function(){
var url = host + 'getUserInfo/'+thisUser.UID;
var wynik;
new Ajax.Request(url,{
method:'post',
onSuccess: function(e) {
wynik = eval('(' + e.responseText + ')');

thisUser.imie = wynik[0].imie;
thisUser.nazw = wynik[0].nazw;
thisUser.phone = wynik[0].phone;
thisUser.email = wynik[0].mail;
thisUser.login = wynik[0].login;



}

});

}

this.Test = function(){
alert("LOGIN:"+thisUser.imie);
}

...
...
.....
}
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 17:23