-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintro-to-ajax.html
74 lines (63 loc) · 1.83 KB
/
intro-to-ajax.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Intro to Ajax</title>
<style>
#murals-info {
margin: 10px auto;
border: 5px ridge blueviolet;
padding: 15px;
width: 25%;
text-align: center;
}
#murals-info:hover {
cursor: pointer;
background-color: aliceblue;
}
#card-section {
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.card {
display: flex;
flex-direction: column;
border: 2px solid darkgray;
padding: 5px;
width: 330px;
}
</style>
</head>
<body>
<section id="murals-info">
<p>I want to know about murals</p>
</section>
<section id="card-section">
</section>
<script
src="https://code.jquery.com/jquery-2.2.4.min.js"
integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="
crossOrigin="anonymous"></script>
<script>
$("#murals-info").click(function(){
$.ajax("/data/murals.json").done(function(data){
data.forEach(function(mural, index){
var title = '';
mural.artwork_title ? title = mural.artwork_title : title = "Untitled";
$("#card-section").append(
'<article class="card">' +
'<p>' + title + '</p>' +
'<p>' + mural.artist_credit + '</p>' +
'<button class="more-info">More Information</button>' +
'<p class="index" style="display: none">'+ index + '</p>' +
'</article>');
});
});
$("#card-section").on('click', '.more-info', function(){
alert('yo');
});
});
</script>
</body>
</html>