In your first example, you're trying to call a .queue() method on the return
value from $.getJSON(). $.getJSON() returns either an XMLHttpRequest object
or nothing. It doesn't return the $ object.

Also, $getJSON() returns *before* the request is completed.

In the second example, you're trying to call a .queue() method on the return
value from $.each(). $.each() returns the object you passed in as its first
argument. So you're calling data.queue() which doesn't exist.

Instead of chaining your calls, you can just make them separate statements:

$.getJSON( "http://....";, function(data) {
    $.each( data, function(i, item) {
        //...
    });
    $.queue(function() {
        $("#div").fadeIn();
    });
});

I must confess I've never used $.queue(), so I don't know if that code is
correct, but at least you wouldn't get the undefined queue method.

But are you simply trying to fade in your div after the $.getJSON() request
is completed and after you run the $.each() loop? You don't need queue for
this:

$.getJSON( "http://....";, function(data) {
    $.each( data, function(i, item) {
        //...
    });
    $("#div").fadeIn();
});

-Mike

On Sun, Sep 20, 2009 at 11:28 AM, cerberos <pe...@whywouldwe.com> wrote:

>
> I'm trying to queue to start once a getJSON request has finished but
> it's not working, I'm getting '...queue is not a function'.
>
> I've tried
>
> $.getJSON("http://....";, function (data){
>  $.each(data, function(i,item){
>     ...
>   });
>  }).queue(function(){
>      $("#div").fadeIn();
> });
>
> and
>
> $.getJSON("http://....";, function (data){
>  $.each(data, function(i,item){
>     ...
>   }).queue(function(){
>      $("#div").fadeIn();
>   });
> });
>
>
> but I get the same error. I've tried with 1.3.2 and 1.2.6.
>

Reply via email to