chat.json:
- JScript code
[ { "name":"11", "age":"22" } ]
json.html:
- HTML code
<!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title>无标题文档</title> <script src="js/jquery-1.6.2.js"></script> <script type="text/javascript"> $().ready(function() { $.getJSON('chat.json',function(data){ alert(data.name); }); }); </script> </head> <body> </body> </html>
------解决方案--------------------
- JScript code
// alert(data.name); //=====> alert(data[0].name);