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

How do I limit the search to let's say 5 or 10 images displayed?

I want to control my program so it displays the exact number of images I want. Also, can someone point me to the good resource to learn to add "loading" wheel when user waits for the AJAX response to happen.

Thanks!

1 Answer

Steven Parker
Steven Parker
182,341 Points

When you display the results, instead of using ".each" to create an element for every image, use another kind of loop where you can specify a limit on the iterations. Or use "slice" to get a subset of "data.items" and run "$.each" on that.

Ans you can easily find "loading animations" or "spinners" with any search engine. Here's a collection of several I spotted in a quick search that are implemented using CSS animations: Loaders and Spinners. Typically, you would display the spinner when you submit the AJAX request, and then hide it when you display request results.