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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Leonardo Motta](https://uploads.teamtreehouse.com/production/profile-photos/10108012/micro_leo.jpg)
Leonardo Motta
11,284 PointsMaking this request with vanilla js
How could I do the jQuery request with vanilla js?
I have this so far:
// Start http request
const xhr = new XMLHttpRequest();
const url = "https://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?";
xhr.onload = function() {
if (xhr.status === 200) {
let returnValue = JSON.parse(xhr.responseText);
console.log(returnValue);
} else {
console.log(this.status);
}
};
xhr.open("GET", url);
xhr.send();
1 Answer
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsIt looks like you have the right idea, but you're trying to access a resource that isn't providing the right information to pass the CORS security requirements of the browser. You may be able to invoke your browser with special options to avoid this issue. For example, for Chrome, you could start it with this command line:
chrome.exe --user-data-dir="C:/Chrome dev session" --disable-web-security
Besides a much more compact syntax, another advantage of jQuery for AJAX is that it internally resolves many CORS issues without special browser settings.