

Ask HN: Where do I start if I want to learn AJAX? - Frocer

AJAX has been something I have always wanted to pick up, but not sure where to begin.  I am not very familiar with Javascript either.  Could you please recommend any online tutorials or book that's good for someone new to AJAX?<p>I have heard AJAX is really hard to pickup without using an existing framework, is that really the case?  If it is, which framework should I begin with? (I actually find that a bit hard to believe, and really want to learn the fundamentals)<p>I have a fair amount of programming experience.  Web development experience is primarily with php/sql, if that helps with any suggestions :)<p>Thanks in advance!
======
jsdalton
Try jquery.

BTW, it's not so much that ajax is "hard" without a framework. The problem is
with the varying ways different browsers implement javascript and the DOM. A
good framework (like jquery) abstracts away many of these variations and
allows you to concentrate on the more interesting hard problems.

~~~
menloparkbum
+1 for jquery, and for the comment suggesting the javascript book. Javascript
and DOM quirks are probably the biggest stumbling blocks if you are already a
decent programmer. Douglas Crockford's videos are also worth watching, if you
have the time. <http://developer.yahoo.com/yui/theater/>

~~~
tlrobinson
+1 for Crockford's lectures. And his website:
<http://www.crockford.com/javascript/>

He's got a new book coming out soon too. I haven't seen it yet, but I imagine
it will be pretty good.

"Javascript: The Definitive Guide" (published by O'Reilly) is a good resource
as well.

------
SwellJoe
If you don't already know JavaScript, and probably even if you do, Douglas
Crockford's videos are awesome. He also covers the DOM, which is intrinsic to
working with AJAX.

<http://developer.yahoo.com/yui/theater/>

Start with "The JavaScript Programming Language", and then do "Advanced
JavaScript" and finally "An Inconvenient API: The Theory of the DOM" (the
latter two can stand alone, and if you're in a hurry, maybe get the DOM out of
the way). That plus spending some time with Firebug and a few interesting
JavaScript applications (and building some of my own) has been the entirety of
my JavaScript education. I bought the "Definitive Guide" from O'Reilly, but
haven't used it heavily.

There are other useful videos on the same page, including one with Joe Hewitt
introducing Firebug. I can't stress enough how helpful Firebug has been in
helping me learn JavaScript and AJAX.

Note that I haven't talked much about AJAX. AJAX is a tiny piece of
JavaScript, but in order to build useful applications you need to know a lot
more than AJAX. So, learn JavaScript and AJAX will come naturally.

As others have mentioned, the good frameworks make dealing with browsers
easier, since it hides compatibility issues as well as some of the complexity.
Mainly a framework just allows you to spend more time thinking about your
specific needs rather than the tedious plumbing work of getting stuff
happening on the page.

~~~
menloparkbum
Oh yeah, +1 Firebug. You need Firebug. Figuring out WTF is going on is nearly
impossible without it, unless you're a masochist and enjoy debugging via alert
dialogs.

~~~
wenbert
and yes, Firebug is a must. the "Inspect" feature is FTW

------
breily
<http://www.w3schools.com/Ajax/Default.Asp>

This gives a pretty good introduction at what is actually going on. The
framework I've used (Prototype) abstracts away the details (like constructing
the XMLHttpRequest) but its always good to know whats going on below the
surface.

If you know any python, this link - <http://www.willarson.com/blog/?p=36> \-
is very helpful, it was how I got started. The actual AJAX part of it is the
same no matter which server side language you use.

~~~
jrockway
Prototype is really a horrible framework. It works by adding methods to every
class in the language, even when they don't make sense. This makes for a bit
of syntactic sugar, but it also ensures that you can't use other frameworks
and that custom code might become very hard to debug.

For your own sake, use _anything_ else.

~~~
sc
Layering frameworks probably isn't a good idea to begin with. Prototype does
seem, unfortunately, more powerful than jQuery, though, when it comes to class
creation.

------
jrockway
The other comments in the thread seem to tell you to use a framework, and
that's great advice. But you need to learn plain javascript first. You say
you've mostly done PHP, so there are some programming concepts that are
essential in javascript that you haven't been exposed to, namely functional
programming. So, learn a bit about functional programming, then get a
javascript book (the oreilly one is good), and read that. Then you'll know the
basics and can use a framework to abstract away some of the tedium.

~~~
amichail
No, you can just use Java with GWT.

------
iraw
You should learn the basics before letting some higher-level framework do all
the magic for you.

There are some good articles about AJAX on the Mozilla Developer Center:
<http://developer.mozilla.org/en/docs/AJAX>

You can begin with <http://developer.mozilla.org/en/docs/AJAX:Getting_Started>

You can also find some good pointers to AJAX toolkits and examples there.

------
Bluem00
I really liked the book "Pragmatic Ajax: A Web 2.0 Primer"
([http://www.amazon.com/Pragmatic-Ajax-
Web-2-0-Primer/dp/09766...](http://www.amazon.com/Pragmatic-Ajax-
Web-2-0-Primer/dp/0976694085/ref=sr_1_1?ie=UTF8&s=books&qid=1209355518&sr=8-1))

It provides an overview of the more popular frameworks, and explains the ideas
behind rich web interaction (and Google Maps in particular).

------
JayNeely
Frocer, I'm in the same position, minus having had a fair amount of
programming experience(only a couple of Java classes in college). Would you be
up for exchanging IM or other contact info, so we each have someone to bounce
things off of as we learn?

My e-mail's in my profile, and the offer is open to others as well.

~~~
Frocer
Absolutely! I will send you an Email and we can exchange info. I am always
looking for people who I can bounce ideas off with :)

------
posborne
The way I picked up AJAX was by looking of some of the simpler articles on the
basics (don't worry about cross-browser to start with) around the web. The
basic concept is quite simple and it is easy to get up-and-running if you have
experience with client-side and server-side scripting.

For me, the firebug tool for firefox was indispensable as it allows you to see
the requests that are being sent out and received from the server, information
you have no easy way to get at without such a tool.

Once you are up and running with the basics, the magic of AJAX will no longer
be so mysterious and you can move on to one of the frameworks for adding
cross-browser compatibility (I like jquery personally).

------
rantfoil
You need to learn Javascript before you learn AJAX. AJAX is really a simple
set of method calls, the harder part is really understanding DOM manipulation,
event handling, etc.

I highly recommend the Sitepoint books -- "Simply Javascript" and "The Art and
Science of Javascript." Between these two books, you get a very step-by-step,
approachable tutorial of the basics of what you need to start out with.

They teach you in framework-agnostic way, which is important because you want
to be able to write JS without relying heavily on any one framework. In fact,
one of the books goes into detail teaching you HOW some frameworks work their
magic. It's fascinating.

Good luck!

------
tlrobinson
If you already know Javascript, all you need to become buzzword compliant is
this:
[http://developer.apple.com/internet/webcontent/xmlhttpreq.ht...](http://developer.apple.com/internet/webcontent/xmlhttpreq.html)

------
brk
Lots of good comments here... <http://www.miniajax.com> has some cool ajax
"widgets" that can help you tackle certain problems with digestible chunks of
code.

------
mxh
[http://www.ibm.com/developerworks/views/web/libraryview.jsp?...](http://www.ibm.com/developerworks/views/web/libraryview.jsp?search_by=Mastering+Ajax)

Particularly tutorial 5.

It's a pretty good/quick overview of how all the bits of Ajax (JS, the DOM,
XHR, Markup, etc.) work together, along with brief, functional examples.
Should get you orientated in a hurry, then you can dive into the various
topics as needed.

------
Dylanfm
I found the book "DOM Scripting" great. There's a brief intro to javascript
syntax, then alot of focus on using javascript with the DOM and making sure
you do it according to some best practices. The book finishes with an intro to
ajax and is followed by a book called "Bulletproof AJAX" by the same bloke.
The gracefully degrading and unobtrusive use of javascript is important, and
the author of these books preaches it well.

------
bprater
If you are familiar with web programming today, Ajax isn't a tough technology
to master. There are hundreds of simple frameworks you can start with. Grab
any of them, find a simple tutorial and start tooling around.

The concept is simple: send and load information without refreshing the
webpage. You'll use the same back-end technology. You'll use a smattering of
Javascript for the browser. And you'll be in business!

~~~
amichail
The problem though is that AJAX app development is a mess (e.g., in terms of
dealing with compatibility issues across browsers and different versions of
the same browser, using the slow minimal dynamic language Javascript, poor
tool support, etc). At least Google's GWT tries to clean up a bit of this
mess. A better way to go in the future might be to use Silverlight.

~~~
axod
It's really not. Compatibility issues are seriously way way over-hyped.

------
axod
Instead of 'ajax' which doesn't really exist, I'd recommend learning
javascript. Don't start with a framework or library, just learn the nuts and
bolts of the language.

The incompatibilities between browsers are really really over-hyped, so I'd
say using a library isn't worth it. At least until you have a solid
understanding of all things javascript.

------
rms
start with javascript...

~~~
rshao
I agree. JavaScript is a pretty crucial step before really tapping into AJAX,
particularly if you want to execute scripts you retrieve via AJAX. I'm not
sure if any script packages have that. Also, I find it useful to work from
scratch, particularly for client-side stuff like CSS and JavaScript, so your
users load the page faster.

~~~
tlrobinson
I can't tell, are you being sarcastic? You realize AJAX is just a fancy name
for using JavaScript to load content dynamically?

------
tokipin
[http://rajshekhar.net/blog/archives/85-Rasmus-30-second-
AJAX...](http://rajshekhar.net/blog/archives/85-Rasmus-30-second-AJAX-
Tutorial.html)

------
amichail
Try Google's GWT.

------
initself
Head First AJAX by O'Reilly.

------
pfisch
Whatever you do do not under any circumstances use plain javascript. It will
not work at all in IE. Isn't it ridiculous that javascript is not even
functional as a language unless you extend it with a framework?

I advise prototype.

~~~
axod
What??? That makes absolutely no sense. Javascript works just fine in IE.

