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 trialbaderbouta
7,804 PointsCan 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
231,268 PointsHi, 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.
paulscanlon
Courses Plus Student 26,735 PointsHey
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
baderbouta
7,804 PointsHey 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?
baderbouta
7,804 PointsJohan Uribe
2,677 PointsI was also wondering if jquery and Ajax were outdated technologies worth learning.
Steven Parker
231,268 PointsThere'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.
baderbouta
7,804 Pointsbaderbouta
7,804 PointsGreat! And I'm assuming the ''fetch'' interface is more native to the browser, correct?
Steven Parker
231,268 PointsSteven Parker
231,268 PointsYes, "fetch" is part of JavaScript.