views:

203

answers:

2

In past i had read the documentation about getJSON and there is an example with a flickr photo api. (the example with the [pussy]cats :-)).

No I ask myself why is it possible, to access flickr directly with this example. Ive tried this by store this code on my local machine - it works but if I use a local copy of jquery i just get an error in firebug like this

$ is not defined myurl/test.html Line 11

Does anybody of you have a solution for this paradox thing?

This is the documentation url HTTP:api.jquery.com/jQuery.getJSON/

The example isn´t also not working if I store the HTTP:code.jquery.com/jquery-latest.js in my local jquery file.

I also dont understand why the request isnt´s visible in Firebug Console

Thank you in advance

Bernhard


EDIT:

I took the example from jquery and just replaced the source with the my local copy of that framework.

<!DOCTYPE html>
<html>
<head>
  <style>img{ height: 100px; float: left; }</style>
  <script src="js/jquery/jjquery-1.4.2.min.js"></script>
</head>
<body>
    <div id="images">

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

Yes of course.

I took the example from jquery and just replaced the source with the my local copy of that framework.

<!DOCTYPE html>

img{ height: 100px; float: left; }

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

Bernhard
A: 

This is a little mistake but not the reason for this error. If you have the time try it yourself

Grab the example on jquery documentation an replace source with official minified version and or the local copy of the source written in example

Thank you

Bernhard
@Bernhard - You can use comments like this one to comment on an answer. I'll give it a try.
patrick dw
@Bernhard - Your code works fine for me. I get four kitten images displayed on my page. If you are getting `$ is not defined`, then that means `$` isn't referencing anything meaningful. In other words, your jQuery is not getting loaded. All I can say is to check again and make sure the path to your jQuery library is correct.
patrick dw