When to use Ajax vs Json for Javascript events?

ajax, json

Solution

Here's some JSON:

{ "taco" : "awesome", "burrito": "less awesome", "fishTaco": "1000" }

Looks pretty much like an array in this case.

And you can use AJAX to get the JSON. I use it to return table data often. You've probably already used JSON-like data in your javascript but didn't realize it.

I prefer to request JSON data rather than XML or HTML. I find it easier to deal with than XML, and more flexible than HTML.

Problem

I'm not so familiar with Ajax but I keep hearing Json mentioned as some kind of competing option. Is there a rule for when to use one versus the other? I'd like to process Javascript events in my app and update the front-end dynamically from the app but I'm not sure whether I need to use Ajax or Json for this.

Original source