Advertisement
Guest User

Untitled

a guest
Dec 11th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. var loadHeros = function(){
  2.  
  3. //Get json asynchronously
  4. $.ajax({
  5. dataType: "json",
  6. url: "data/herosJSON.json",
  7. mimeType: "application/json",
  8.  
  9. success: function(result){
  10.  
  11. //The table element on hero's page.
  12. var table = $('#heroTable');
  13.  
  14. //Loop through each object in JSON appending them
  15. $.each(result, function(i, obj){
  16.  
  17. $('#heroTable').append($(
  18. "<tr><td>" + obj.TITLE + "</td>" +
  19. "<td>" + obj.SUBJECT + "</td>" +
  20. "<td>" + obj.SOURCE + "</td>"+
  21. "<td>" + result[i].PUBL.DATES + "</td>"+
  22. "<td>" + obj.HISTORY + "</td>"+
  23. "<td>" + obj["DESCRIPT."] + "</td>"+
  24. "<td>" + obj.SUBJECT + "</td></tr>"
  25. ));
  26. });
  27.  
  28. //Log json to check it's there
  29. //console.log(result);
  30. }
  31.  
  32. });
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement