Json file is a lightweight data interaction format. The getJSON () method is generally used in jquery to read data. The sample code is as follows. For more information, see, it is expected that your json file is a lightweight data interaction format. GetJSON () is generally used in jquery to read data.
The Code is as follows:
$. GetJSON (url, [data], [callback])
Url: the address of the loaded page.
Data: Optional. data sent to the server. The format is key/value.
Callback: Optional. callback Function executed after successful Loading
1. Create a JSON Format File userinfo. json to save user information. As follows:
The Code is as follows:
[
{
"Name": "Zhang Guoli ",
"Sex": "male ",
"Email": "zhangguoli@123.com"
},
{
"Name": "Zhang tielin ",
"Sex": "male ",
"Email": "zhangtieli@123.com"
},
{
"Name": "Deng Yi ",
"Sex": "female ",
"Email": "zhenjie@123.com"
}
]
2. Create a page to obtain the user information data in the JSON file and display
The Code is as follows:
GetJSON