0

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!

The Bndr
  • 13,204
  • 16
  • 68
  • 107

1 Answers1

0

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);
                            });
                        });
}
Eric Hodonsky
  • 5,617
  • 4
  • 26
  • 36
  • >"I think your main problem was the single quotes" - absolutely - that was the point! oO Thank you. Why you are using slideUp? to "hide" the element before? Is'n it possible to use ` – The Bndr Mar 05 '12 at 10:05
  • yeah, but then it flickers real quick. You can do either for sure, this was just the 'ease in' and 'ease out' example. – Eric Hodonsky Mar 12 '12 at 22:01