AJAX
AJAX (asynchronous JavaScript and XML) is used to exchange data with a server, and JSON (JavaScript Object Notation) is used to store and structure information in a logical way.
- update a web page without reloading the page
- request data from server after the page has loaded
- receive data from server after the page has loaded
- send data to server in the background
AJAX and JSON
We can use PHP to send JSON encoded data into web applications.
- make an Ajax request that returns the .json file data
- parse the data from the .json file back in JavaScript
- loop over all incoming objects
{ "u1": {"user":"Diane", "city":"Austin" }, "u2": {"user":"Susie", "city":"San Diego" }, "u3": {"user":"Lorie", "city":"Laramie" } }
JSON and PHP
foobar is 1234567
JSON.parse
Hello