Answer the question
In order to leave comments, you need to log in
How can I display the comment form on button click?
In general, I need to display the comment form by clicking on the button, an example like this: vintagetechnics.ru/comment
I tried to implement it this way, but nothing is displayed:
$(document).on("click", '#comment .add-btn', function(e) {
e.preventDefault();
var data = {
action: 'comment_form',
}
$.ajax({
type: "POST",
url: comment_reviews_form.ajax_url,
data: data,
dataType: 'json',
success: function(data) {
console.log(data);
if (data.success) {
console.log(data);
}
},
error: function(xhr) {
}
});
return false;
});
add_action( 'wp_ajax_comment_form', 'vintage_technics_comment_form' );
add_action( 'wp_ajax_nopriv_comment_form', 'vintage_technics_comment_form' );
function vintage_technics_comment_form() {
wp_send_json_success( comments_template() );
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question