First, the server. Our server here is very simple, but of course it could easily retrieve data from a database. The data structure that this example sends is also very simple, but JSON can send data structures that are as complex as you like.
Let's imagine you run this on your local machine and access it with a URL like this: http://localhost/test.php?id=goodbye
What you get back looks like this:
Here we see some simple data in standard JSON format.
Here's the alert that this page pops up:
jQuery also defines a more complex AJAX call routine, in case you want to check for possible failure or have a timeout or whatever.