user2860857
user2860857

Reputation: 559

fade in after ajax call

I have the following code and try to make the result of the ajax fade in

$.post('e.php', {term: $(this).text()} , function(data) {
                $('#dictionary').html(data).fadeIn("slow");
})

This is not working. How I must edit it, to make the results fade in the div?

Thanks in advance

EDIT

Everything works fine, except the effect, it doesnt take place. I see the results appear in the div, not fade in it.

Upvotes: 0

Views: 1776

Answers (2)

David
David

Reputation: 219057

In response to your comment:

@David yes it is visible

What do you expect .fadeIn() to do on an element that's already visible? There's nothing to "fade in." The element needs to be hidden first. Either style it to be hidden by default via CSS:

#dictionary {
    display: none;
}

Or hide it inline with the JavaScript code:

$('#dictionary').hide().html(data).fadeIn("slow");

Upvotes: 0

rgajrawala
rgajrawala

Reputation: 2188

It may have to do with the fact that #dictionary might be visible before the fadeIn() call. See this question.

Upvotes: 1

Related Questions