Is it better to learn how to code AJAX without the use of an AJAX library? What are the advantages of coding from scratch over using a library such as jQuery?
For learning, yes, avoid libraries. Especially for something as conceptually simple as AJAX, forcing yourself to learn how the browser can be used “raw” will benefit you immensely later on, even if you are using a library to take care of the drudgery and abstract away browser differences.
While I think it is really important to understand conceptually what is going on and be able to correctly implement calls using an AJAX library, I disagree with @Shog9 that you need to write the actual code to perform an XmlHttpRequest in order to start using AJAX. I’d say do some background reading to understand the concepts — implement the code samples demonstrating them if you want — but once you get the concept, find some tutorials on how to do stuff with AJAX with or without libraries. You’ll soon find that others have been there before and left pretty good sign-posts on how to get around.
I agree with the sentiment about looking at framework code to see how to write good code.
Well it depends…
Do you want so get productive fast? then JQuery or any other framework of your choice is the way.
Warning: I love jQuery, my opinion is biased
Learning do if yourself
Otherwise do yourself and your deadlines a favour and use the library.
Every generation of technology makes learning the previous generation less useful, even though it could give you more power.
Example: Millions learned Visual Basic even though writing your own C gives you more control.
Answer to the question:
If you want to learn about AJAX, study how the libraries use AJAX. They are open source. They have been matured over time and are commented well.
If you want to USE AJAX, then just use one of the libraries and save yourself a world of headache.
I think it’s all a matter of what your end goal is. If your looking to have a good fundamental understanding of AJAX so you can make educated decisions about which framework is best and why certain things work then learning AJAX without the help of a framework is best for you. If your goal to learn how to architect dynamic websites and AJAX is the missing link in your understanding, then I see no harm in learning based on a framework. Besides, how often do you really need to understand the fundamentals of a technology. In the same way that you don’t really need to know how to use the WinHttp object to be able to make Http requests in .Net, for the most part you don’t need to know how to use the XmlHttpRequest object because your likely going to be using some form of interface to access it anyway.