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

JavaScript AJAX Basics (retiring) AJAX and APIs Stage 4 Challenge Answer

Kahriq Chatmon
Kahriq Chatmon
8,694 Points

Flickr API Challenge with no jQuery

Is it possible to use the regular Javascript AJAX code we learn at the beginning of the AJAX Basics course to refactor this challenge?

2 Answers

Steven Parker
Steven Parker
231,172 Points

It's possible, but AJAX may be the place where jQuery shines brightest. Besides greatly simplifying the request syntax, it performs some functions "under the hood" that might be particularly difficult to replicate such as resolving many CORS security issues.

I'll use jQuery in a project where it is already loaded, but I typically won't load it myself and code in pure JavaScript. But AJAX is the one exception where I will always pull in jQuery to do the job.

Masha Blair
Masha Blair
13,005 Points

You should use Fetch API -- which is a new, native JS API for making AJAX requests instead of vanilla JS. Treehouse has a class for it. It's just as simple as jQuery AJAX.

Steven Parker
Steven Parker
231,172 Points

Fetch is indeed cool, and easy to use, but it still doesn't resolve CORS issues for you the way jQuery/AJAX does.