-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.htm
105 lines (77 loc) · 2.54 KB
/
index.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<!DOCTYPE html>
<!--
File Name: ehCode_2018.06.13_demo_AjaxJson
Date Created: 06/13/18
Programmer: Eric Hepperle
Purpose: Demonstrates grabbing and displaying data from JSON endpoints
using AJAX and vanilla JavaScript ES6.
Usage:
1. Load the HTML page in a browser.
2. Click the button to load new objects.
3. Each object should display in a styled, floated block module.
Sample results: N/A
Requires:
* A web browser.
* REST API Web Service data locations:
-- https://learnwebcode.github.io/json-example/animals-1.json
Demonstrates:
* Vanilla JavaScript
* AJAX
* XMLHttpRequest
* Parsing JSON
* REST API
Based on this tutorial:
- Title: JSON and AJAX Tutorial: With Real Examples
- URL: https://www.youtube.com/watch?v=rJesac0_Ftw
- Channel: LearnWebCode
Resources:
- Where to access json endpoint urls:
-- Fill Text: http://www.filltext.com/
- JavaScript Templating: handlebars.js
- Error Handling for AJAX?
-->
<html lang="en">
<head>
<!-- Meta Tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Stylesheets -->
<link rel="stylesheet" href="styles.css">
<!-- Fonts -->
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Tangerine|Open+Sans|Jua:400,300,700">
<title>JSON and AJAX</title>
</head>
<body>
<header>
<h1>JSON and AJAX</h1>
<button id="btn">Fetch Info for 3 New Animals</button>
</header>
<div id="animal-info"></div>
<!-- TESTING -->
<hr style="clear: both; margin: 2em;">
<section class='animal_profile'>
<h3>data[i].name</h3>
<table id='tbl_dataname'>
<tr>
<td><h4>Species:</h4></td>
<td>data[i].species</td>
</tr>
<tr>
<td colspan="2"><h4>Foods:</h4></td>
</tr>
<tr>
<td><h5>Likes</h5></td>
<td><h5>Dislikes</h5></td>
</tr>
<tr>
<td>likesString</td>
<td>dislikesString</td>
</tr>
</table>
</section>
<!-- JavaScripts -->
<!-- NOTE: Scripts go at bottom before the closing body tag, listed in order of dependency. jquery.js is always first. -->
<script src="https:/ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<script src="main.js"></script>
</body>
</html>