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) jQuery and AJAX jQuery’s AJAX Shorthand Methods

Can I just use vanilla JS for AJAX calls? Jquery is almost too easy.

Sounds strange, but writing all those lines of vanilla JS made more intuitive sense to me than Jquery, it's almost too simple... as strange as that may sound.

Is it fine if I proceed not to use Jquery for AJAX calls?

4 Answers

Steven Parker
Steven Parker
229,732 Points

:bell: Hi, I got alerted by your tag.

Coding AJAX can be a pain (or "challenge") using basic XMLHttpRequests. You might try it once or twice for a learning exercise, but I can't imagine you'd want to do that in general. The new "fetch" interface is about as easy to use as jQuery, but one advantage jQuery still has is that it recognizes and handles common CORS (security) issues that can be a problem with either the basic interface or fetch.

I'd probably favor "fetch" when there are no problems, and good old jQuery if there are CORS issues due to the server(s) not sending all the correct headers.

Great! And I'm assuming the ''fetch'' interface is more native to the browser, correct?

Steven Parker
Steven Parker
229,732 Points

Yes, "fetch" is part of JavaScript.

Hey

Try reading this.

(https://www.w3schools.com/xml/xml_http.asp)

Also there is the fetch api which is more flexible and promise based.

Hope this helps

Happy coding

Paul

Hey Paul, thanks for help and link, is it fair to say that this current course on Jquery AJAX handling (these: https://teamtreehouse.com/library/ajax-basics/jquery-and-ajax/the-office-status-project-revisited) are a bit outdated and would be wiser to follow what you sent me?

Johan Uribe
Johan Uribe
2,677 Points

I was also wondering if jquery and Ajax were outdated technologies worth learning.

Steven Parker
Steven Parker
229,732 Points

There's a lot more to jQuery than just AJAX, and a lot of modern frameworks depend on it, so I don't think it's likely to become outdated anytime soon.

And while you may only code AJAX using jQuery or Fetch, it's still good to at least know how the primitive calls work.