loading content with $.get and slideDown the updadet element

588 views Asked by At

i'm trying to load data into an element using jQuery.get. After loading is completed, an div should be updated with that content in order to slideDown the content.

For an example please take a look at this fiddle: http://jsfiddle.net/7BKXq/1/ ..where you can find the following conde:

function loadAndOpen(parent)
{
    var o_parent=$(parent);
    var url="jttp://myurl";
    o_parent.append('<div id="content">...loading...</div>');
     jQuery.get(url,function(data)
                        {
                        o_parent.find('#content')
                            .html(data)
                            .hide()
                            .slideDown('8000');
                        }
                    )   ;
}

The Problem is, that slideDown displays the element after loading the content, but not sliding it smoothly.

Probably there is an wrong useage of the .slideDown method?

Thank you!

1

There are 1 answers

2
Eric Hodonsky On BEST ANSWER

I think your main problem was the single quotes around the slideDown time, it made it a string instead of an integer.

I did a little editing, I still don't like the way you call the function, but honestly I can't make it do what I want with a jQuery event watcher: http://jsfiddle.net/7BKXq/8/

function loadAndOpen(parent){
    var o_parent=$(parent);
    if(o_parent.children().length > 0) o_parent.children().remove();
    var url="http://api.geonames.org/postalCodeLookupJSON?postalcode=6600&country=AT&username=demo";
    o_parent.append('<div id="content">...loading...</div>');
     jQuery.get(url,function(data)
                        {
                        o_parent.find('#content')
                            .slideUp(100, function(){
                                $(this).html(data).slideDown(8000);
                            });
                        });
}