tobmes
Goto Top

Wartefunktion

Hi,

ich habe mal wieder ein kleines Problemchen. Ich habe diese JavaScript Funktion

var fail = $("<p/>", {  
            html: "Dies ist ein Test",  
            "class": "alert"  
        });
        fail.appendTo("#test").fadeIn("slow").fadeOut(3000);  

        return false;
    } else {
        var ok = $("<p/>", {  
            html: "Daten erfolgreich gespeichert",  
            "class": "allRight"  
        });
        ok.appendTo("#test").fadeIn("slow").fadeOut(3000);  

    }

    return true;

Leider wird der else-Zweig dann zwar korrekt ausgeführt, die Ausgabe ist aber nur ganz kurz zu sehen. Ich würde da also gerne solange warten, bis das FadeOut fertig ist. Leider habe ich aber gerade keine Ahnung wie ich das machen soll. Kann mir da jemand helfen? Und gäbe es hier eigentlich auch einen Ansatzpunkt für XSS? Das würde ich nämlich gerne unterbinden, ist zwar nur zum rumspielen, aber würde das gerne relativ sicher programmieren.


Danke schon mal.

Content-Key: 310709

Url: https://administrator.de/contentid/310709

Printed on: April 24, 2024 at 00:04 o'clock

Mitglied: 129813
129813 Jul 23, 2016 updated at 19:56:24 (UTC)
Goto Top
Hi.
That's normal because jQuery animations are executed asynchronously in a non blocking thread, so the animation starts in your function and the function quits directly after the call to animate the stuff where all local variables etc. are destroyed. So define your animating variables outside the function or you should better take the event approach from the animate() function. There is a callback-function which is called when the animation is over.
http://stackoverflow.com/questions/1594077/jquery-synchronous-animation

jQuery is a dynamic event driven framework you should read about.

Regards