-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeedback.js
42 lines (39 loc) · 1.19 KB
/
feedback.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
(function feedbackWrapper($) {
EatLogGo.checkLogin();
$("#submit-feedback").click(handleSend);
function handleSend(e) {
e.preventDefault();
submitFeedback($("#feedback_text").val());
}
function submitFeedback(feedback) {
$.ajax({
method: 'POST',
url: _config.api.invokeUrl + '/feedback',
headers: {
"Authorization": EatLogGo.globalAuthToken,
},
data: JSON.stringify({
Email: EatLogGo.loggedInUser,
Feedback: feedback,
}),
contentType: 'application/json',
beforeSend: function Processing() {
$("#submit-feedback").removeClass("btn-primary")
.addClass("btn-secondary")
.off("click",submitFeedback)
.text("Submitting....");
},
success: function() {
alert("Feedback submitted!");
EatLogGo.redirectTo("log.html");
},
error: function ajaxError(jqXHR, textStatus, errorThrown) {
alert('An error occured when submitting your feedback\n');
$("#submit-feedback").removeClass("btn-secondary")
.addClass("btn-primary")
.on("click",handleSend)
.text("Submit");
}
});
}
}(jQuery));