A simple example is :
This script will popup an alert dialog box with the text 'John.'
The JSON block can support nested types as well as arrays. For example:
{
"firstName": "John",
"lastName": "Smith",
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": 10021
},
"phoneNumbers": [
"212 555-1234",
"646 555-4567"
]
}
Typically the JSON request will come from the server, or through a Ajax callback or some other technique. This approach is must easier to work with then returning XML that the JavaScript client then has to parse.
No comments:
Post a Comment