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

Jaime Rios
PLUS
Jaime Rios
Courses Plus Student 21,100 Points

AJAX with JavaScript or jQuery?

When developing your work projects, how do you use AJAX, with JavaScript or jQuery and why?

Personally, I'm currently prefering working with Jquery, as it has so much built-in functionality that is easy to use. I find it faster to code and it has less issues.

2 Answers

Ognjen Jevremovic
Ognjen Jevremovic
13,028 Points

Hello Jaime. How are you?

Recently I've been working on some web app in which I needed to make a JSONP (JSON with padding) which basically allows you to bypass the same origin policy and load JSON from an external server into the javascript, or in other words (as instructors here on TH stated) - JSONP was designed to allow you to request JSON resources from a different webserver (no the one hosting your website).

Anyways, to answer your question, I think that's just a personal preference. I, for example, feel more comfortable working with jQuery and I use it in 90%+ of the time and in my code (I only use vanilla JS for canvas object, cursor position, loops, etc).

I like how jQuery market itself with a line "Write less do more", which basically is the main concept behind any library. Instead of making http request object, making the callback function, opening the http request object and sending the data to a webserver (4 steps of an AJAX request), you can shorten it up to just a few 'property-value' pairs, used inside of jQuery $.ajax function.

Try both and see what works best for you. Either way, you can't make a mistake. Once again, it's just a personal preference.

My way of thinking about it is - 'Why reinvent the wheel?'. You should (or perhaps, it would be a good choice - some would argue it's a must) learn the both, just so you can see how JavaScript operates in the back, from your jQuery code.

A bit off topic, but somehow related, is the Chalker's blog post I'd like to reference here. It's a good read! You can find it on the link down below: http://blog.teamtreehouse.com/im-allowed-cheat

Hope that helps. Cheers pal!

Javascript is the language. jQuery is a library, written is Javascript. You can send AJAX requests using jQuery or even without so you can send AJAX request written in pure Javascript as well.