-
Notifications
You must be signed in to change notification settings - Fork 0
/
scripts.js
executable file
·60 lines (43 loc) · 1.34 KB
/
scripts.js
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
var API_ENDPOINT = "https://<uniquehash>.execute-api.<aws.region>.amazonaws.com/prod"
function showOpinion() {
$.ajax({
url: API_ENDPOINT + '/list',
type: 'GET',
success: function (response) {
jQuery.each(response, function(i,data) {
if (data['published'] == true) {
$("#opinion").append("<div class='col-lg-12'> \
<div class='frequent_item'> \
<h3>" + data['message'] + "</h3> \
<p align='right'>" + data['name'] + ", " + data['firm'] + "</p> \
</div> \
</div>");
}
});
},
error: function () {
alert("error");
}
});
};
document.getElementById("addOpinion").onclick = function(){
var inputData = {
"name": $('#postName').val(),
"firm": $('#postFirm').val(),
"email" : $('#postEmail').val(),
"message" : $('#postMessage').val()
};
$.ajax({
url: API_ENDPOINT + '/sendMail',
type: 'POST',
data: JSON.stringify(inputData) ,
contentType: 'application/json; charset=utf-8',
success: function (response) {
document.getElementById("postReturn").textContent="Thank you! Opinion added to database. Publication will be after acceptance adminisrator of this site.";
},
error: function () {
alert("error");
}
});
};
showOpinion()