Fixed posting flags towards the server

This commit is contained in:
Nanne Baars
2017-04-15 14:01:34 +02:00
parent 6f633a0f78
commit 7ff5503241
7 changed files with 83 additions and 74 deletions

View File

@ -4,10 +4,15 @@ $(document).ready(function () {
$.ajax({
type: 'POST',
url: 'challenge/3',
data: JSON.stringify ({comment: commentInput}),
data: JSON.stringify({comment: commentInput}),
contentType: "application/json",
dataType: 'json'
});
}).then(
function () {
getChallenges();
$("#commentInput").val('');
}
)
})
var html = '<li class="comment">' +
@ -23,13 +28,18 @@ $(document).ready(function () {
'</div>' +
'</li>';
$.get("challenge/3", function (result, status) {
for (var i = 0; i < result.length; i++) {
var comment = html.replace('USER', result[i].user);
comment = comment.replace('DATETIME', result[i].dateTime);
comment = comment.replace('COMMENT', result[i].comment);
$("#list").append(comment);
}
getChallenges();
});
function getChallenges() {
$("#list").empty();
$.get("challenge/3", function (result, status) {
for (var i = 0; i < result.length; i++) {
var comment = html.replace('USER', result[i].user);
comment = comment.replace('DATETIME', result[i].dateTime);
comment = comment.replace('COMMENT', result[i].comment);
$("#list").append(comment);
}
});
}
})