Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Nick Tolbert
12,003 Points[RESOLVED]am getting a console error: XMLHttpRequest cannot load(flickr's api)... No 'Access-Control-Allow-Origin'
this is the error am getting: XMLHttpRequest cannot load https://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?&tags=Dog&format=json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://port-80-50q8a9sfan.treehouse-app.com' is therefore not allowed access.
is this because of my code or flickr?
$('document').ready(function(){
//$("button").on
$('button').click(function(){
$('button').removeClass('selected');
$(this).addClass('selected');
//$.get(flickerAPI,func...)
var flickerAPI = "https://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?";
var animal = $(this).text();
var flickeropt = {
tags:animal,
format:'json'
};
function displayPhotos(data){
var photoHTML ="<ul>";
$.each(data.items,function(i,photo){
photoHTML +='<li class="grid-25 table-grid-50">';
photoHTML+= '<a href="'+photo.item.link+'"class="image">';
photoHTML+='<image scr="'+ photo.item.media.m+'"></image></a></li>';
});//end each
photoHTML+='</ul>';
$('#photos').html(photoHTML);
};//end callback
$.get(flickerAPI,flickeropt,displayPhotos);
});//end button
//.append(<img>)
});//end ready
2 Answers
MIke Allen
9,727 PointsHi Nick,
I think its because you are using the https version of Flickr api.
I have this as my address and it works fine http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?
Hope that helps.
Nick Tolbert
12,003 PointsI want back an look over my code and I made 3 small errors and 2 big ones ; namely using ('document').ready()... and $.get instead of (document).ready()... and $.getJSON. .
Nick Tolbert
12,003 PointsNick Tolbert
12,003 Pointsunfortunately, am still getting the same error. do you know of any API I can replace (key free) this with or any other way of testing; to know if my code works ?