Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "users": [
- {
- "id": 1,
- "name": "Ian",
- "login": [
- "January 10, 2016",
- "February 1, 2016"
- ]
- },
- {
- "id": 2,
- "name": "Sam",
- "login": [
- "January 16, 2016",
- "February 1, 2014"
- ]
- }
- ]
- }
- <script type="text/javascript">
- $("document").ready(function(){
- //get the XML data and add list items
- var url = "users.json";
- $.getJSON(url, function (data) {
- console.log(data);
- console.log("Printing data.users");
- console.log(data.users);
- $.each(data.users, function(i,val){
- $("<li></li>")
- .html(val)
- .appendTo("ul#userList");
- });
- });
- });
- </script>
- </head>
- <body>
- <h1>Reading from and JSON Document using jQuery.getJSON()</h1>
- <ul id="userList"></ul>
- </body>
- <script type="text/javascript">
- $("document").ready(function(){
- //get the XML data and add list items
- var url = "users.json";
- $.getJSON(url, function (data) {
- console.log(data);
- console.log("Printing data.users");
- console.log(data.users);
- var val = [];
- $.each(data.users, function(i,val){
- $("<li></li>")
- .html(val.id)
- .appendTo("ul#userList");
- });
- });
- });
- </script>
- </head>
- <body>
- <h1>Reading from and JSON Document using jQuery.getJSON()</h1>
- <ul id="userList"></ul>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement