Demo: jQuery Ajax Call to PHP Script with JSON Return
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>
- Full JSON return is accessed via data["json"]
- Individual JSON data can be accessed via data["name"]