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

Going to another page without refreshing the current page

I want to ask that how I would go to another page without refreshing the current page. By just the <a></a> but adding a JQuery code to it. I saw a lot of websites doing this and it's pretty useful. Any idea.

1 Answer

Kevin Korte
Kevin Korte
28,148 Points

It's called ajax. jQuery helps a lot here. Basically you are sending the server data, and the server does something with the data, and sends the new information, or "page" back, all without a page refresh.

I used ajax on a site I'm still working on. I still have a lot of work, but check out the filter tab option. When you select an option in my dropdown, it filters the available post and it loads the next dropdown with appropriate data. Each time you use the select drop down, my WP loop changes again. It'll ultimate be more useful when I have a lot more posts on there.

FYI, you can use your browser dev tools and look at my ajax script to see how I'm making the calls. I do have some refactoring to do with the code, but it's at least functional. It's sending the data to a file that does a WP query.

The whole site itself is still a work in progress. I know I have a few errors.

www.machinecheatsheet.com

Andrew Chalkley
Andrew Chalkley
Treehouse Guest Teacher

Hi there,

I wrote a quick post a while ago on A Quick Guide to Understanding AJAX. Also Dave McFarland is going to be releasing a full course on it later this month. It's called AJAX Basics.