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
182,492 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
12,999 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
182,492 Points

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