Example

Favorite beverage:
Favorite restaurant:
Gender:
JSON:
  

Usage

If you are running this locally, files must be running via a virtual server on your machine with PHP installed.

Reminder: Don't forget to include the jQuery library.
Put the following in the <head>:

<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>

https://gist.github.com/3739844#js-ajax-php-json-usage.html
  • Full JSON return is accessed via data["json"]
  • Individual JSON data can be accessed via data["name"]
https://gist.github.com/3739844#response.php

Read the Tutorial