Is there a way to display data instantly after submitting a form via AJAX and saving it through a controller function? I want to be able to view the saved data on the same page without having to refresh it:
<span class=" store_comment_like " data-comment-id="{{ $comment->id }}" > </span>
$(document).ready(function() {
$('.post-comment').click(function(e){
e.preventDefault();
var commentId = $(this).attr('data-comment-id');
var data= {
commentId:commentId,
method:'POST',
}
$.ajax({
url:'/schooldukan/post/comment/'+commentId,
type: 'POST',
dataType: "JSON",
data: data,
success: function(data) {
printSuccessMsg(data.success);
$('#commentonpost2')[0].reset();
} else {
printErrorMsg(data.error);
}
}
});