The two functions you have chained (empty, append) are both synchronous, so
the next line shouldn't execute until they are done. You say it sometimes
works, sometime not. When it doesn't work, is .message .content empty? or
does it have the old/not yet updated content?

- Richard

On Dec 14, 2007 2:51 PM, Eric Teubert <[EMAIL PROTECTED]> wrote:

>
> Hi there,
>
> I struggle with execution time of JS. As any line after some other
> does not wait for the line before to be executed, my script works
> sometimes ... and sometimes not. It looks like that:
>
>        $.ajax({
>                ...
>                success: function(msg){
>                                if (msg!='') {
>                                        $("#"+eleID+" .message
> .content").empty().append(msg);
>                                        onReadyStuff(eleID);
>                                        }
>                                }
>        });
>
> Most times I execute the script, "onReadyStuff()" is faster than the
> line before but is has to be executed after append(); What I need is
> something like
>
> $("#"+eleID+" .message .content").empty().append(msg, function()
> {onReadyStuff(eleID);});
>
> How do I do this?
>
> Eric
>

Reply via email to