I want to display the received data, which I got with ajax from php code. I tried it with jquery.append(), but after I refresh the page the appended html is gone. How can I append html and let it stay on the website even when refreshing
I'm working on a Comment System btw.
ajax code:
var comment = "";
$("#form").on("submit", function(e) {
e.preventDefault();
$.ajax({
url: "test.php",
method: "POST",
dataType: "json",
data: form.serialize(),
success: function (r) {
console.log(r);
comment = r.comment;
$(".show-comments-container").append(`<div class='show-comment'><h3>`+comment+`</h3></div>`);
},
error: function(jqXHR, textStatus, errorMessage) {
console.log(errorMessage);
}
});
});
Aucun commentaire:
Enregistrer un commentaire