Advertisement
Guest User

Untitled

a guest
Feb 5th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. {
  2. "users": [
  3. {
  4.  
  5. "id": 1,
  6. "name": "Ian",
  7. "login": [
  8. "January 10, 2016",
  9. "February 1, 2016"
  10. ]
  11. },
  12.  
  13. {
  14.  
  15. "id": 2,
  16. "name": "Sam",
  17. "login": [
  18. "January 16, 2016",
  19. "February 1, 2014"
  20. ]
  21. }
  22. ]
  23.  
  24. }
  25.  
  26. <script type="text/javascript">
  27. $("document").ready(function(){
  28. //get the XML data and add list items
  29. var url = "users.json";
  30. $.getJSON(url, function (data) {
  31. console.log(data);
  32. console.log("Printing data.users");
  33. console.log(data.users);
  34. $.each(data.users, function(i,val){
  35. $("<li></li>")
  36. .html(val)
  37. .appendTo("ul#userList");
  38.  
  39. });
  40.  
  41. });
  42.  
  43. });
  44.  
  45. </script>
  46. </head>
  47. <body>
  48. <h1>Reading from and JSON Document using jQuery.getJSON()</h1>
  49. <ul id="userList"></ul>
  50. </body>
  51.  
  52. <script type="text/javascript">
  53. $("document").ready(function(){
  54. //get the XML data and add list items
  55. var url = "users.json";
  56. $.getJSON(url, function (data) {
  57. console.log(data);
  58. console.log("Printing data.users");
  59. console.log(data.users);
  60. var val = [];
  61. $.each(data.users, function(i,val){
  62. $("<li></li>")
  63. .html(val.id)
  64. .appendTo("ul#userList");
  65.  
  66. });
  67.  
  68. });
  69.  
  70. });
  71.  
  72. </script>
  73. </head>
  74. <body>
  75. <h1>Reading from and JSON Document using jQuery.getJSON()</h1>
  76. <ul id="userList"></ul>
  77. </body>
  78. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement