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 Displaying the Photos

How to send off request during page load

Wondering how to get it so the first tag loads automatically and then a new request is sent when the link is clicked.

1 Answer

rydavim
rydavim
18,813 Points

If you're on the bit where there are a couple of button to click that change the photos that are being fetched, you can just trigger a click on that button when the page loads.

$('button')[0].click();

The above will click the first button, and load the corresponding flickr photos. Doing it this way also helps preserve active styling.

Let me know if that isn't what you meant, and we can explore other options available. Happy coding! :)