change comments to use ajax
This commit is contained in:
@@ -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']));
|
||||
test_input($_POST['newcomment-content']))) {
|
||||
echo 1;
|
||||
} else {
|
||||
echo 0;
|
||||
}
|
||||
}
|
||||
|
||||
header("Location: ../profile.php");
|
||||
18
website/public/js/post.js
Normal file
18
website/public/js/post.js
Normal file
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
function loadPost(postID) {
|
||||
$.get(
|
||||
"API/loadPost.php",
|
||||
$(postID).serialize()
|
||||
).done(function (data) {
|
||||
$('#modal-response').innerHTML= JSON.parse(data);
|
||||
});
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<?php include("../views/head.php"); ?>
|
||||
<script src="js/masonry.js"></script>
|
||||
<!-- <script src="js/profile.js"></script>-->
|
||||
<script src="js/post.js"></script>
|
||||
<style>
|
||||
@import url("styles/profile.css");
|
||||
@import url("styles/post-popup.css");
|
||||
|
||||
@@ -21,9 +21,9 @@ echo("
|
||||
|
||||
<div class='post-comments'>
|
||||
<div class="commentfield">
|
||||
<form action="API/postComment.php" name="newcomment" method="post">
|
||||
<input type="hidden" name="postID" value="<?= $postID ?>">
|
||||
<textarea name="newcomment-content" Laat een reactie achter..."></textarea> <br>
|
||||
<form id="newcommentform" action="javascript:postComment();">
|
||||
<input type="hidden" id="newcomment-textarea" name="postID" value="<?= $postID ?>">
|
||||
<textarea id="newcomment" name="newcomment-content" placeholder="Laat een reactie achter..."></textarea> <br>
|
||||
<input type="submit" value="Reageer!">
|
||||
</form>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user