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 trialmatt thurmond
8,743 PointsIs AJAX still relevant?
Hi! I'm wondering if learning AJAX is still relevant given that frameworks like React and Angular seem to handle this asynchronous server request-response functionality in a different way.
Since the course is long, it would be good to know if learning this is relevant in today's environment. Thanks!
2 Answers
Eric Butler
33,512 PointsAJAX is still relevant and very popular, but how you write it may change based on what libraries or frameworks are in the project. I almost never use the "raw" JavaScript way of writing it because jQuery makes it easier and is almost always already loaded into a project I'm working on. I'll also point out that despite what code-camps and web-dev courses make it look like, the vast majority of websites are not using React or Angular or any full-stack JavaScript framework: it's simply too much tool for the job. If all you need is some AJAX, putting an entire Node-based build process into your project is going to drive you nuts. Of course, if you ARE exclusively using one of those frameworks, then yeah, just learn how to do asynchronous API calls "their way." Good luck to you!
Brendan Whiting
Front End Web Development Techdegree Graduate 84,738 PointsThe modern way is the Fetch API (Treehouse workshop here). Not all browsers have it, but there are polyfills for that. This isn't a React or Angular thing, it's a modern browser thing.
(Side note, modern Angular has the HttpClient which returns an Observable and operates a little differently than fetch).
Eric Butler
33,512 PointsIf anyone reads this and wonders "which browsers don't have it?" the big one that matters is Internet Explorer (all versions). Here's the full breakdown.
Brendan Whiting
Front End Web Development Techdegree Graduate 84,738 PointsIt's interested that Opera mini doesn't have AJAX either: https://caniuse.com/#search=XMLHttpRequest
matt thurmond
8,743 Pointsmatt thurmond
8,743 PointsThanks, I'm realizing that web developers need to know a variety of ways of doing things and adjust their approach depending on the project scope and existing frameworks and libraries that are already implemented. It seems like a good baseline to know how to use both the Fetch API and XHR to handle requests and responses, and then I can expand on that by learning any framework specific approaches to this used by React, Angular, and other front-end frameworks.
Since I'm half-way through the AJAX course now, I'll definitely complete it.
Eric Butler
33,512 PointsEric Butler
33,512 PointsMatt, I think that's an excellent approach. Good luck to you!