Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [programowanie obiektowe] odwołąnie do funkcji w klasie
flashdev
post
Post #1





Grupa: Zarejestrowani
Postów: 812
Pomógł: 117
Dołączył: 2.12.2008

Ostrzeżenie: (10%)
X----


Witam,

piszę klasę w javascript i utknąłem na pewnym problemie.
A mianowicie w jednej z funkcji wywołuję zapytanie (ajax) do serwera. I teraz przy odebraniu wyniku z serwera, w miejscu gdzie umieściłem funkcję alert chciałbym odwołać się do innej funkcji w klasie.
W jaki sposób to zrobić?

Kod
// include: jQery

    this.funkcja = function(){        
        $.ajax({
            type: 'POST',
            url: ...,
            data: ...,
            success: function(str){
                alert(str);
            }
        });
    }
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 1)
#luq
post
Post #2





Grupa: Zarejestrowani
Postów: 589
Pomógł: 91
Dołączył: 22.05.2008
Skąd: Gliwice

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


Kod
this.foo = function(){
    // somthing
}

this.funkcja = function(){        
    var thisInstance = this;    

    $.ajax({
        type: 'POST',
        url: ...,
        data: ...,
        success: function(str){
            //alert(str);
            thisInstance.foo();
        }
    });
}
Go to the top of the page
+Quote Post

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: 25.08.2025 - 12:06