Google Groups Home Help | Sign in
$getJSON problem...demo works, but not my code?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Andy Matthews  
View profile
 More options Mar 12, 10:38 pm
From: Andy Matthews <andyandja...@gmail.com>
Date: Wed, 12 Mar 2008 19:38:41 -0700 (PDT)
Local: Wed, Mar 12 2008 10:38 pm
Subject: $getJSON problem...demo works, but not my code?
I've got an AIR app I'm working on, one in which I'll be needing to
make a few calls from the user's desktop to our login server. I found
on the jQuery site where it says that cross domain calls work fine if
you return JSON data using the JSONP format. The demo works just fine,
but when I try to replicate it using my code, I get no data, or an
error. Can anyone tell me what I'm missing? Here's the two samples,
the one copied straight from the docs, the other copied and pasted
from my code:

$.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?
tags=cat&tagmode=any&format=json&jsoncallback=?",
        function(data){
                alert(data);
                $.each(data.items, function(i,item){
                        $("<img/>").attr("src", item.media.m).appendTo("#content");
                        if ( i == 3 ) return false;
                }
        );

});

$.getJSON("http://www.commadelimited.com/uploads/bullhorn/bullhorn.cfc?
method=retriveData&jsoncallback=?",
        function(data){
                alert(1);
        }
);

The docs go about 85% of the way in explaining what I'm supposed to
do, so I guess I need what's in the other 15%.

Anyone have any ideas?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
MorningZ  
View profile
 More options Mar 13, 7:35 am
From: MorningZ <morni...@gmail.com>
Date: Thu, 13 Mar 2008 04:35:53 -0700 (PDT)
Local: Thurs, Mar 13 2008 7:35 am
Subject: Re: $getJSON problem...demo works, but not my code?
When you say "get an error", what's the error?

Do you use Firebug (http://www.getfirebug.com) at all to help? it's
great to help diagnose script/AJAX problems


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andy Matthews  
View profile
 More options Mar 13, 7:51 am
From: Andy Matthews <andyandja...@gmail.com>
Date: Thu, 13 Mar 2008 04:51:30 -0700 (PDT)
Local: Thurs, Mar 13 2008 7:51 am
Subject: Re: $getJSON problem...demo works, but not my code?
For the above code sample, it correctly throws an alert, then outputs
images of cats into the specified container.

For my code it does nothing. No errors, but also no alert. It's almost
like it's not returning anything to the page, but in Firebug I see
that the call is being made. In fact, here's the URL that Firebug
shows is going out:

http://www.commadelimited.com/uploads/bullhorn/bullhorn.cfc?method=re...

On Mar 13, 6:35 am, MorningZ <morni...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Danny  
View profile
 More options Mar 13, 8:54 am
From: Danny <d.wac...@prodigy.net>
Date: Thu, 13 Mar 2008 05:54:43 -0700 (PDT)
Local: Thurs, Mar 13 2008 8:54 am
Subject: Re: $getJSON problem...demo works, but not my code?
Try going to the commadelimited.com URL directly in your browser. It
looks like it's not returning the correct JSONP format.
Flickr returns (with callback=foo in the URL):
foo( {...json...} )
and commadelimited returns:
[ {...json...} ]

So it looks like the problem is on the server side.

Remember, jQuery uses JSONP by creating a <script> element and using
the URL as the src attribute, so the returned text is executed as
javascript.
foo( {...json...} );
calls the function foo with the relevant data so you can use it.
[ {...json...} ];
creates an array with the data but promptly throws it away.

Danny

On Mar 13, 6:51 am, Andy Matthews <andyandja...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andy Matthews  
View profile
 More options Mar 13, 10:33 am
From: "Andy Matthews" <li...@commadelimited.com>
Date: Thu, 13 Mar 2008 09:33:40 -0500
Local: Thurs, Mar 13 2008 10:33 am
Subject: RE: [jQuery] Re: $getJSON problem...demo works, but not my code?
Danny...

But when I view both URLs directly in the browser there appears to be no
difference in the return.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
MorningZ  
View profile
 More options Mar 13, 10:58 am
From: MorningZ <morni...@gmail.com>
Date: Thu, 13 Mar 2008 07:58:56 -0700 (PDT)
Local: Thurs, Mar 13 2008 10:58 am
Subject: Re: $getJSON problem...demo works, but not my code?
"there appears to be no difference in the return."

There is a difference....

on the Flickr return

({ ....  })    parenthesis as the outer syntax

and on CommaDelimited

[{ .... }]     square brackets as the outer syntax

Minor difference i know, but it could be the difference in work and
not work


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
jforth  
View profile
 More options Mar 13, 9:16 am
From: jforth <jfo...@gmail.com>
Date: Thu, 13 Mar 2008 06:16:30 -0700 (PDT)
Local: Thurs, Mar 13 2008 9:16 am
Subject: Re: $getJSON problem...demo works, but not my code?
I had an issue like this...

what I had to do is structure the data from the server like this:
myfunction({json_here})

//Get JSON

$.getJSON("http://www.commadelimited.com/uploads/bullhorn/bullhorn.cfc?
method=retriveData&myfunction=?");

//Create function

function myfunction(data){
   //do whatever

}

On Mar 13, 8:54 am, Danny <d.wac...@prodigy.net> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Danny  
View profile
 More options Mar 13, 2:29 pm
From: Danny <d.wac...@prodigy.net>
Date: Thu, 13 Mar 2008 11:29:15 -0700 (PDT)
Local: Thurs, Mar 13 2008 2:29 pm
Subject: Re: $getJSON problem...demo works, but not my code?
jQuery replaces the '?' in the URL with a function name. Try the URL's
with something like 'callback=foo' in there; you'll notice that Flickr
puts that name in the return as a function call (' foo( {..})') while
your's still returns just [ {..} ]. And yes, using square brackets
instead of parentheses will give an error if you use them in a
function call

On Mar 13, 9:33 am, "Andy Matthews" <li...@commadelimited.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andy Matthews  
View profile
 More options Mar 13, 4:59 pm
From: "Andy Matthews" <li...@commadelimited.com>
Date: Thu, 13 Mar 2008 15:59:38 -0500
Local: Thurs, Mar 13 2008 4:59 pm
Subject: RE: [jQuery] Re: $getJSON problem...demo works, but not my code?
I talked it over with a co-worker and it appears that this is more an issue
with ColdFusion's version of JSON. I don't think that ColdFusion understands
JSONp at the moment.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google