diff --git a/website/public/API/postComment.php b/website/public/API/postComment.php index c5b30cc..b840e0b 100644 --- a/website/public/API/postComment.php +++ b/website/public/API/postComment.php @@ -5,12 +5,14 @@ session_start(); require("../../queries/post.php"); require("../../queries/connect.php"); require("../../queries/checkInput.php"); - if (empty($_POST['newcomment-content'])) { + echo 0; } else { - makeComment($_POST['postID'], + if(makeComment($_POST['postID'], $_SESSION['userID'], - test_input($_POST['newcomment-content'])); -} - -header("Location: ../profile.php"); \ No newline at end of file + test_input($_POST['newcomment-content']))) { + echo 1; + } else { + echo 0; + } +} \ No newline at end of file diff --git a/website/public/js/post.js b/website/public/js/post.js new file mode 100644 index 0000000..62ace68 --- /dev/null +++ b/website/public/js/post.js @@ -0,0 +1,18 @@ +function postComment() { + $.post( + "API/postComment.php", + $("#newcommentform").serialize() + ); + + $("#newcomment").val(""); + + //reload post + $.get( + "API/loadPost.php", + $("#newcommentform").serialize() + ).done(function (data) { + $('#modal-response').html(data); + }); +} + + diff --git a/website/public/js/profile.js b/website/public/js/profile.js index 2a47dce..e69de29 100644 --- a/website/public/js/profile.js +++ b/website/public/js/profile.js @@ -1,8 +0,0 @@ -function loadPost(postID) { - $.get( - "API/loadPost.php", - $(postID).serialize() - ).done(function (data) { - $('#modal-response').innerHTML= JSON.parse(data); - }); -} \ No newline at end of file diff --git a/website/public/profile.php b/website/public/profile.php index d2d3c3f..c8f27c4 100644 --- a/website/public/profile.php +++ b/website/public/profile.php @@ -3,7 +3,7 @@
- +