Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
218,635 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
218,635 Points

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