I don't see anything physically wrong with a nested $.getJSON.  I
suspect either your code or the return results.

I would extract the two callback functions into actual functions rather
than just inline.  Then I think you should be able to use Firebug's
breakpoints on the callbacks to step through the code.

Matt Penner
Database Engineer II
GIS Support
[EMAIL PROTECTED]
(951) 940-6108 x10709

-----Original Message-----
From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Mark Lacas
Sent: Monday, November 12, 2007 2:04 AM
To: jQuery (English)
Subject: [jQuery] Re: Nested getJSON


It appears that I can't nest getJSON calls.

When I make the second call, the throbber in Firebug spins forever.

I'm getting a list of changes from a database and then trying to get
more precise data on each change with a second  getJSON call in an
anonymous function in the first getJSON call.

Can anyone enlighten me on this?


On Nov 11, 10:07 am, herbasher <[EMAIL PROTECTED]> wrote:
> Pretty, pretty.
>
> What's your problem?
>
> What are you working on?
>
> Herb
>
> On Nov 10, 3:45 pm, Mark Lacas <[EMAIL PROTECTED]> wrote:
>
> > Here is my code:
>
> > $.getJSON("/cgi-bin/messages.cgi", { id: last_message },
> > function( json ) {
>
> >         $.each( json.messages, function( i, item ){
>
> >                 if ( item.command == "new" ) {
> >                         $.getJSON("/cgi-bin/get_data.cgi", { id:
item.id, fields: "all" },
> > function( json ) {
>
> >                                 $.each( json.objects, function( i,
item ){
> >                                         create_object( item );
> >                                         //return false;
> >                                 });
> >                         });
>
> >                 } else if ( item.command == "change" ){
> >                         $.getJSON("/cgi-bin/get_data.cgi", { id:
item.target, fields:
> > "all" }, function( json ) {
>
> >                                 $.each( json.dp_objects, function(
i, item ) {
> >                                         update_object( item );
> >                                 });
> >                         });
>
> >                 } else if ( item.command == "delete" ){
> >                         $(".object[id_num=item.target]").remove();
>
> >                 }
> >         });
>
> > });

Reply via email to