Whats up with cross site Scripting (getJSON) and flickr example
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&tagmode=any&format=json&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>
Yes of course.
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&tagmode=any&format=json&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>
精彩评论