Comment Submission Without Page Refresh. No Plugins Used.
I know there are so much ready services for website comments like facebook and disqus but I like the default WordPress comment system the most because of the following benefits:
- simple for user understanding — the users know that when they fill name, email, comment text and click the submit button – the comment will appear. No additional actions.
- for me the default WP comments means full control under them. I decide how to filter them from spam, I decide what HTML tags to allow in comment body, I can force users to purchase a website membership before submitting a comment etc. By the way I redesigned my WordPress dashboard a little – the latest 30 comments are showing there now.
AJAX Comments Requirements
Before we begin coding there would be some more text to read. I suggest you to overview the AJAX comment functionality we will create.
- One of the most wanted functions – support of nested comments with
comment-reply.js
. - All the comment errors should be displayed properly. For simpleness I will do it with the JavaScript
alert()
function in this post. - Remove disallowed HTML tags from comment text.
- Comment moderation.
- Save in cookies the values of user Name and Email fields.
- No WordPress plugins. No plugins at all :)
Step 1. Can not imagine that HTML could be the most difficult part? Surprise!
If you do not have the advanced level of knowing such things as DOM traversal, please, be very careful at this step.
I begin with the words that each WordPress theme differs. In this post I will make the AJAX comments for WordPress default TwentySeventeen theme, but I can not even imagine what theme you will use.
You shouldn’t copy this code anywhere – just look if your theme comment structure is similar to it, if no – you should make changes either in your theme HTML structure or in Step 3 of this tutorial.
<!-- it can be <ul> or <ol> element -->
<ol class="comment-list">
<!-- more classes can be inside, we need only "comment" and "depth-#" -->
<li id="comment-1" class="comment depth-1">
<!-- article tag can also have ID and Classes but it doesn't matter for us -->
<article>
<!-- comment content and comment meta is here -->
<!-- just make sure that <div class="reply"> is the last element inside article -->
<div class="reply">
<a class="comment-reply-link">Reply</a>
</div>
</article>
<!-- nested comment replies are here -->
<ol class="children">
<!-- comment <li> elements are the same like in depth-1 level -->
</ol>
</li>
</ol>
<div id="respond">
<!-- form is here -->
<!-- make sure that all the name attributes and ID of the <form> are correct -->
</div>
Step 2. Enqueue Scripts in functions.php
Our task in this step is to include to our website pages jQuery, our custom script and print the URL of the WordPress AJAX.
For your functions.php
:
add_action( 'wp_enqueue_scripts', 'misha_ajax_comments_scripts' );
function misha_ajax_comments_scripts() {
// I think jQuery is already included in your theme, check it yourself
wp_enqueue_script('jquery');
// just register for now, we will enqueue it below
wp_register_script( 'ajax_comment', get_stylesheet_directory_uri() . '/ajax-comment.js', array('jquery') );
// let's pass ajaxurl here, you can do it directly in JavaScript but sometimes it can cause problems, so better is PHP
wp_localize_script( 'ajax_comment', 'misha_ajax_comment_params', array(
'ajaxurl' => site_url() . '/wp-admin/admin-ajax.php'
) );
wp_enqueue_script( 'ajax_comment' );
}
First of all let’s check if everything has been made correctly. Open your website, then go to browser console. There should be a 404 error for ajax-comment.js
.

No error? Hmmm, haven’t you created ajax-comment.js
yet? If not, check that your theme header has wp_head()
function and your theme footer has wp_footer()
function.
Only when you got this 404 error, you can create ajax-comment.js
file in your theme directory. I’m asking about it because if you’re a beginner in coding, this small debug tip will be helpful for you.
Also open your website source HTML and check if ajaxurl
parameter is there. Is everything ok? Proceed to the next step.
Step 3. jQuery code for ajax-comment.js
If your HTML comment structure is the same as described below or maybe your are using TwentySeventeen theme – in these cases you can insert the below code without changes at all.
/*
* Let's begin with validation functions
*/
jQuery.extend(jQuery.fn, {
/*
* check if field value lenth more than 3 symbols ( for name and comment )
*/
validate: function () {
if (jQuery(this).val().length < 3) {jQuery(this).addClass('error');return false} else {jQuery(this).removeClass('error');return true}
},
/*
* check if email is correct
* add to your CSS the styles of .error field, for example border-color:red;
*/
validateEmail: function () {
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/,
emailToValidate = jQuery(this).val();
if (!emailReg.test( emailToValidate ) || emailToValidate == "") {
jQuery(this).addClass('error');return false
} else {
jQuery(this).removeClass('error');return true
}
},
});
jQuery(function($){
/*
* On comment form submit
*/
$( '#commentform' ).submit(function(){
// define some vars
var button = $('#submit'), // submit button
respond = $('#respond'), // comment form container
commentlist = $('.comment-list'), // comment list container
cancelreplylink = $('#cancel-comment-reply-link');
// if user is logged in, do not validate author and email fields
if( $( '#author' ).length )
$( '#author' ).validate();
if( $( '#email' ).length )
$( '#email' ).validateEmail();
// validate comment in any case
$( '#comment' ).validate();
// if comment form isn't in process, submit it
if ( !button.hasClass( 'loadingform' ) && !$( '#author' ).hasClass( 'error' ) && !$( '#email' ).hasClass( 'error' ) && !$( '#comment' ).hasClass( 'error' ) ){
// ajax request
$.ajax({
type : 'POST',
url : misha_ajax_comment_params.ajaxurl, // admin-ajax.php URL
data: $(this).serialize() + '&action=ajaxcomments', // send form data + action parameter
beforeSend: function(xhr){
// what to do just after the form has been submitted
button.addClass('loadingform').val('Loading...');
},
error: function (request, status, error) {
if( status == 500 ){
alert( 'Error while adding comment' );
} else if( status == 'timeout' ){
alert('Error: Server doesn\'t respond.');
} else {
// process WordPress errors
var wpErrorHtml = request.responseText.split("<p>"),
wpErrorStr = wpErrorHtml[1].split("</p>");
alert( wpErrorStr[0] );
}
},
success: function ( addedCommentHTML ) {
// if this post already has comments
if( commentlist.length > 0 ){
// if in reply to another comment
if( respond.parent().hasClass( 'comment' ) ){
// if the other replies exist
if( respond.parent().children( '.children' ).length ){
respond.parent().children( '.children' ).append( addedCommentHTML );
} else {
// if no replies, add <ol class="children">
addedCommentHTML = '<ol class="children">' + addedCommentHTML + '</ol>';
respond.parent().append( addedCommentHTML );
}
// close respond form
cancelreplylink.trigger("click");
} else {
// simple comment
commentlist.append( addedCommentHTML );
}
}else{
// if no comments yet
addedCommentHTML = '<ol class="comment-list">' + addedCommentHTML + '</ol>';
respond.before( $(addedCommentHTML) );
}
// clear textarea field
$('#comment').val('');
},
complete: function(){
// what to do after a comment has been added
button.removeClass( 'loadingform' ).val( 'Post Comment' );
}
});
}
return false;
});
});
Do you want me to describe how AJAX in WordPress works?
- WordPress AJAX URL is always the same
/wp-admin/admin-ajax.php
. - You pass parameters to the script as usual, but you should add
action
parameter (it can be a hidden field in your form as well). - The
action
parameter is connected to hooks infunctions.php
–wp_ajax_{action}
for registered users andwp_ajax_nopriv_{action}
for unregistered ones.
Step 4. Generate and Publish a Comment in PHP
In the code below there is a function wp_handle_comment_submission()
that appeared in WordPress 4.4. If you need the code for the earlier version of WP, just ask me in comments.
<?php
add_action( 'wp_ajax_ajaxcomments', 'misha_submit_ajax_comment' ); // wp_ajax_{action} for registered user
add_action( 'wp_ajax_nopriv_ajaxcomments', 'misha_submit_ajax_comment' ); // wp_ajax_nopriv_{action} for not registered users
function misha_submit_ajax_comment(){
/*
* Wow, this cool function appeared in WordPress 4.4.0, before that my code was muuuuch mooore longer
*
* @since 4.4.0
*/
$comment = wp_handle_comment_submission( wp_unslash( $_POST ) );
if ( is_wp_error( $comment ) ) {
$error_data = intval( $comment->get_error_data() );
if ( ! empty( $error_data ) ) {
wp_die( '<p>' . $comment->get_error_message() . '</p>', __( 'Comment Submission Failure' ), array( 'response' => $error_data, 'back_link' => true ) );
} else {
wp_die( 'Unknown error' );
}
}
/*
* Set Cookies
*/
$user = wp_get_current_user();
do_action('set_comment_cookies', $comment, $user);
/*
* If you do not like this loop, pass the comment depth from JavaScript code
*/
$comment_depth = 1;
$comment_parent = $comment->comment_parent;
while( $comment_parent ){
$comment_depth++;
$parent_comment = get_comment( $comment_parent );
$comment_parent = $parent_comment->comment_parent;
}
/*
* Set the globals, so our comment functions below will work correctly
*/
$GLOBALS['comment'] = $comment;
$GLOBALS['comment_depth'] = $comment_depth;
/*
* Here is the comment template, you can configure it for your website
* or you can try to find a ready function in your theme files
*/
$comment_html = '<li ' . comment_class('', null, null, false ) . ' id="comment-' . get_comment_ID() . '">
<article class="comment-body" id="div-comment-' . get_comment_ID() . '">
<footer class="comment-meta">
<div class="comment-author vcard">
' . get_avatar( $comment, 100 ) . '
<b class="fn">' . get_comment_author_link() . '</b> <span class="says">says:</span>
</div>
<div class="comment-metadata">
<a href="' . esc_url( get_comment_link( $comment->comment_ID ) ) . '">' . sprintf('%1$s at %2$s', get_comment_date(), get_comment_time() ) . '</a>';
if( $edit_link = get_edit_comment_link() )
$comment_html .= '<span class="edit-link"><a class="comment-edit-link" href="' . $edit_link . '">Edit</a></span>';
$comment_html .= '</div>';
if ( $comment->comment_approved == '0' )
$comment_html .= '<p class="comment-awaiting-moderation">Your comment is awaiting moderation.</p>';
$comment_html .= '</footer>
<div class="comment-content">' . apply_filters( 'comment_text', get_comment_text( $comment ), $comment ) . '</div>
</article>
</li>';
echo $comment_html;
die();
}
Some ideas for you, I didn’t add it to the post because I want to make it as simple as possible:
- After the comment is submitted you can update the comment count everywhere on the page.
- You can style beautifully validation errors.
- Use animated SVG preloader.

Misha Rudrastyh
Hey guys and welcome to my website. For more than 10 years I've been doing my best to share with you some superb WordPress guides and tips for free.
Need some developer help? Contact me
Thanks for the article. Does it work with plugins like Comments With Images?
I didn’t have a chance to test :) I think yes.
Thanks a lot for your help. As you seem to love simplicity and lazzyness as I do, I found that I can use the comment callback of the theme to generate a perfectly styled comment html :
1/ look for wp_list_comments() function in your templates and get the name of the callback function passed in arguments
2/in step 4 (line 48)
Works perfectly for me.
Great, thanks for sharing this.
Thanx :)
Great article man!
Hi Misha, thanks for sharing the script!
For wp version like 4.7.5 the default wp_handle_comment_submission is not working.
I’ve to do something else?
thank you.
Hi Pietro!
Make sure that in your comment form you use the default comment form field NAME attributes ( author, email, comment, comment_post_ID ). For me it works beautifully.
It works, thank you!
Great, bookmarked this page, gonna try this out. Thanks!
great article
this is a big test to test awesome
I have been trying to implement this idea for months and finally found a tutorial for it!
This is a test comment.
Hello Misha,
Thanks for this awesome tutorial. I’m currently using a Genesis child-theme and I want to have a comment form that is 100% like your current comment form (this one).
I’ve tried this tutorial but it didn’t work and the comment does not get posted and I didn’t implement the step #4 as I don’t know where to add the code in the theme!
Could you please send me the PHP, JS, and CSS codes? and advice me how to implement it.
All the best.
Hello,
Actually all the code is here in post :) Really.
On what step are you stopped? Step #4 code is for your current theme
functions.php
file.Hello world
Wow, very nice commenting method. I like it. I think I will try this on my site. Thanks for the resources.
This is great. Thanks!
thanks man
hey when i put the fourth step the functions it breaks my theme and where do i put step 1 please do i just copy the whole code and erase and paste in my comments php thank you. and i’m using twenty seventeen theme
Hey Mark,
You shouldn’t paste the code from Step 1 anywhere, it just illustrates you the recommended HTML structure.
As for Step 4 – maybe you should remove line 1? Do not you know how to use
<?php
and?>
?Thanks i fixed the php function .it’s the first step that i don’t understand sorry if i’m disturbing you i’m a newbie. can you give me an example thank you
The first step is just demonstrates the recommended order of HTML elements with its classes and IDs. I suppose you should learn a little about how to work with DOM structure.
ok, so if i’m getting you right the classes are supposed to be there and if they are there the ajax will do the rest?
Yes, Mark, correct.
AJAX completely fxxked up my work
I hope this will work
Thanks for this fruitfull article.
Have to know one thing that how you change this comment box behaviour ???
Thanks in advance
Hi Ravi,
What do you mean?
I mean how you change the wordpress function comment_form() design.
2 options are there – you can read this function documentation or use your custom form (I use a custom one).
Okay thannks buddy for your support.
Your content is simply fantastic!
Thank you :)
Thanks! Great article.
Wonderful!
Hi !
Thanks for this great article !
I just have a question : Is it possible to use a diffrent form for reply comment ?
Thank you !
Hi Julia,
You can style it with CSS as you want ;)
Excellent article! This is really helpful to used my business site development. It just made my work easier. Great work.
Thanks.
Glad to help, you’re welcome!
Well, I’ve got to try it out.
Great article
Happy I found this article.
Kind thanks.
I like custom made stuff…although I am only starting to learn JS.
I have not tried it yet as is (I already like it) …but there is one more dimension I look for.
The ability to add comments functionality as a widget (or a shortcode) anywhere I want, not just at the end of the page/post. Ideally add it within a column, using a page builder like VC or KC.
Any advice how should I do this..?
Nice Man! ! !
Just learn a little about custom widgets and shortcodes I suppose :) And if you would like multiple comment widgets, use HTML classes instead of IDs.
Thank you for the very useful article.
I have a question. What if I want to add “vote up” and “vote down” buttons.
+1 ajax request and store data in commentmeta.
Thank you for article :)
wonderful…
Test
just a test here
testing
testing
I want load more comment page using ajax, not reload page. Please!
Maybe I will write a post about it later. Have to ready code at this moment.
Teste
Thank you for sharing
Line 87 in the javascript has a little issue. You open with a ol tag and close with a ul
Thank you Scott, it is fixed.
hello
Thank you for the code.
It’s great instruction, thanks.
Clean code
i’m reading your article about comments ajax i think i will use it
wahooooo it’s fantastic, thank’you
problème , dont work for me where , must i paste the step 4 ?
i’m using wordpress 4.8.1 version
misha , can you help me ? , i want to show you the page where i want to use your code for comment , problem is not working maybe showing you the page , you can give me your help. thank you for response
Hi,
Just describe me exactly how it doesn’t work.
Hi, first scuse me for my english , i speak french. i’m in Paris,
i’ve do every step like yon showed on your tutoriel , but the template comment don’t display on my page. i don’t know why , may be i’ve do something not right but i wanna talk with you for something very important , maybe we can work togheter about it , and don’t worry it’s will not be for free. is very important my friend , we can not talk about it here you have my email ,i’ll wait for your message , and i will send you the website we have making for our projet, and we’ll talk about something we want to do, maybe you can do this work. thank so much Misha.
Contacted you by email.
Great Tutorial! Thanks a lot!
Thanks
Thank you for this tutorial.
Test comment
Buen aporte!
Thanks
This comments section it’s amazing
Just testing nested comments
awesome . posted in year 2017
hi , thanks for sharing. do you have the php code for current wordpress please. ?
also i assume the div and span doesnt matter but the class name does, am i right on this ? thanks
Hi,
but the code from this post is for the current WordPress version.
Ok, thanks , its working , prefer this than the plugin mode. thanks for sharing.
sorry , checking , does this code also include the leave comment button and its animation actions ? thanks
No id doesn’t
could you share with us that too ? thanks !
Right click in browser and then “Inspect element” 🙃
i begin to replace my plugins with hardcode , with some of the awesome post you’ve been sharing here. perhaps you should start a new trend of selling codes for a small fee rather then selling/providing plugins.
a big thank you.
I’m glad to help 🙃
Plugins are not always bad. But it is better to avoid some of them if you want to have a faster and more secure website.
Testando comentários em Ajax!
Hooooooow!
Works!!!!!!!!
Thanks!
Hi , thanks for sharing , can we have the loading bar added for UI pls :)
Thank you for this code help… please make a post about creating comment template.I want to make a custom comment template.
Ok, I will
test demo test
Nice
How would you make reply link to work with custom format? For me it works perfectly fine except it reply link isn’t being rendered.
E.g. my code for reply link is
But how you do you get
args
array outside the callback?Hi Nick,
I don’t get
$args
array outside the callback.Sorry if I wasn’t clear.
I meant I was extending your code to include reply link in the comment (the snippet is what I added to the
$comment_html
). I could’t get it to work because of undefined$args
so reply link wasn’t generated and shown after comment was loaded with JavaScript.I fixed it though with getting
max_depth
from theme options with theget_option
.Hope it makes sense.
Nice
thanks
Interesting
Test reply
Perfect!
Great! Thank you!
Test
Hi, this is great ajax reply comment to test.
Here is a great testing comment…
Test Commenst
tes
Awesome tutorial
Great info. I’ve got a pretty different approach going but reading this tutorial helped me a bunch & gave me a better understanding of how doing ajax comments in WordPress should work behind the scenes.
Works perfect. Except that the comments appear at the bottom of the comments list, not at the correct spot. How can I figure out whats wrong? =) Thanks
Found the mistake. The script was navigating the DOM a little incorrectly as I hadn’t created the span class anchor in my : <span class='anchored' id='comment-‘>. Added this just after the and voila. Worked like a charm! =) Thanks a lot Misha for a great script!
I’m glad you’ve figured it out! Always welcome 🙃
nice ! thanks
Cheers Man
Just a test
Test comment
Nice tutorial
asdas
this is my comment i am leaving
Yes, nice one!
Nice tutorial.
hi this is really neat
Thanks!
hi
Thanks for that script, works great!
Testing
Nice job, thanks ;-)
Nice job, thanks ;-)
testing
test
Testing reply method
3rd level test… and test editing comments, moderation etc
Commenting to test this … sorry
Just another test. Sorry for this spam.
If comments can be submitted with ajax, it is worth to consider.
This is just the information I was looking for – helping me change the default comments to a more user friendly and engaging solution using AJAX.
Just found your blog and it’s amazing! Great info!
Any post on how to implement that languages toolbar above the comment form? my blog is all about coding in wordpress and it would be great to have such a solution in it..
Thanks!
I LIKE CATS!
Ok 😼
I’m pretty sure I’ve done all the steps. I search the problem : it dont do anything when I submit the comment (click on Submit do nothing).
JS url is OK, functions added to my functions.php file. I use the same ID and class (WordPress defaut)…
Cant find… help ?
Ok I did some tests.
Commented code that valide fields. Now it works. But it is really long to post the comment (button still loading many seconds.
Another thing : when I try to send the form with empty comment textbox, it push the WordPress error. It could be cool to hide it after some seconds cause it stay on the page even if I try again to send the form (with data in the text field).
Thanks
Hey Dominic,
If takes really long to post a comment, you have to check the overall website performance (the amount of plugins, slow code etc).
If you want to hide the error message after some seconds, the very simple jQuery
.delay()
method should help you.Thanks for the reply. Your code worked with jquery validation plugin instead. Using the submithandler function. But the ajax not working on mobile. Im trying to find why.
Your code is really nice. Searched 2 hours before to find yours
Very good
je
i’m going to test this
Such a great example… was very helpful to me
how about using wp_insert_comment function?
Use it if you want 🙃
Hi, I think I did everything right but somehow it only shows 2 of the comments list. Am I missing something? Likewise, the “Loading…” on the “before: function() ” didn’t seem to work.
Hey,
There is no way to understand what is wrong in your code. I could try to help you with the code, just contact me and send me the website URL.
Hello Misha,
Actually it’s still on a localhost environment. I’m going to upload it once the files are ready.
Looking forward to digging into this and making it work on our site. Thanks.
thank
hello
it not working with me ?
where should i use misha_submit_ajax_comment ?
Hello,
in
functions.php
.just test :)
Hi! Thanks for this great piece of code! Just one question, I cannot find the part in which I can “filter” the comment text and get rid of the html tags… can you please tell? Thanks!
Hi,
Everything is inside
wp_handle_comment_submission()
function.Great tutorial, thank !
Great example. that work form me. thanks!
this is a test
Nice comment article, thx
:)
:)
Great man. Very helpful
Great article man! Thank you for this, you saved me so much time! :)
Test
Error :(
/wp-admin/admin-ajax.php 409 (Conflict)
Followed your awesome tutorial and everything is working on single.php. Curious though how I would get this to work on archive.php as well?
Thanks a lot bro!
No, this is not a test at all ^_^
Thanks
Thanks for your great tuto! Very useful.
Can you add the part for respond comment?
I see it’s available of your website.
Welcome!
Your theme default respond form should be ok.
nice!!!
greeat thing!!
great
hello, thanks!
good!!!
Magnífico artículo, tu aporte enriquece enormemente el poderío de WordPress
Gracias !!!
hello
Hi,
Thank you for tutorial,
How i can integrate simple captcha ?
I tried to use “invisble recaptcha google”, but it loads the page
any ideas ?
Hey Misha,
thank you very much for posting this code. I’m trying to get it to work on my site, but every time I try to post a comment, I get the error “ERROR: Please enter a comment”. What could I be doing wrong?
I tried commenting as a logged in user, as well as a non-logged in user, using inkognito mode. Both times I get the same error.
The ajax-comment.js seems to be loading, as my button is being renamed, the “loading” message is being displayed, and the comment field is being cleared after I send the comment. Can you please give me some info on what I’m doing wrong? You can see an example at https://www.alohastone.com/2018/06/10/tom-misch-rhythm-roulette-against-the-clock/
Thanks in advance!
Hey,
It is because your comment field name attribute is
4368d7fb72
, but notcomment
🙃Ooooh, right. Didn’t notice that. Thanks for having a look.
Seems like it’s my Anti-Spam plugin, which is replacing the comment form with a different one. Even says in the FAQ that it’s not compatible with AJAX-powered comment forms. That’s a pity :(
Anyways, great code Misha, and a really beautiful website you’re having here. Keep on doing what you’re doing.
Hmmm, try this line in Step 4:
Hope it helps, but not sure.
Thank you very much! 😊
Thank you for the useful post!
Great. thanks :)
Its very usefull and easy to integrate… Thanks a lot
it is a reply, not a disrespectful one
TEst
hi
Cool tutorial! Going to try this out :)
Nice tutorial
As I have already # in my url so will this work?
It has to work for you, yes
Going to try this out :)
nice code thanks
is working fine
but when use plugin “Invisible reCaptcha for WordPress”
is not working
can you help me?
I could be wrong, but I think you do not need it anymore. Just do not forget to disable non-ajax comments.
just trying out
hello
Not working for me, form just submits as normal, when I added e.prevendefault it just stop doing anything.
nice, thank you very much for the knowledge
Hello, This looks so great!!
It works very well. If anyone didn’t work, please check the description what Rubrastyh wrote.
A question, how can we make like your comment here ( where I am writing)?
I love to add “php, js, html, css.. etc”.
Any insturction?
Thank you,
Sm
Testing ajax?
Testing your comments. I have a multi-site project I am building that uses two sites installed on a multisite network. The main blog’s comments work great but the second site on the subdomain’s comments redirect to the subdomain’s root URL. Seems like a small error but I still need to fix it.
I am going to try and get your Ajax method working on the site. So thank you for the code. I have done full conflict testing and nothing works.
thank you! does this tutorial goes with the comments load more?
AWESOME tutorial!
Fantastic, many thanks
Truly great tutorial :)
truly great tutorial
truly great tutorial
Thank you, wish this work on my project!
Nice article
wanting to test and edit it a bit more for my projects. Seems good.
Nice job
Good job
Great job budyd
Nice
hello man its just a test
Testing the example
Great Tutorial, thanks!
Hi this is from Bond, James Bond.
007
Hi Misha,
Hope all is well.
came across this great tutorial again and thought about integrating autorefresh of any new comments that may be posted while a user is on a post. (either automatically loaded or more like twitter with a button/notification alerting user of new comments being posted since they have been on the page…)
(Of course also making it so it can be conditionally loaded for a certain page/post only, like a main activity stream, or for specific user roles only).
I may give this a shot when having time, but I still thought I’d throw it out there to you.
Cheers!
Hi Cross,
Yep, that would be a cool feature, especially if a website has a lot of commenters. I thought about publishing a tut about Heartbeat API, maybe I will do it later.
Thanks!
This is great
Yes!
Hello
Thank you!
Just testing if you’re using it on this site ;)
Yes, I am 🙃
Looks and works awesomely. Thanks for sharing it!
Thank you
Hello
Thank you!
Thanks!!
Thanks.
can make popup reCAPTCHA (google chaptcha)
before fade data?
Hey Mirane,
But why? Do you receive spam comments?
Just checkin’ it out, looks pretty cool. :)
This is awesome
Did you managed to fix the problems with nesting?
Test
thanks
Test, Thanks.
OH, so fast comment :)
I don’t know why in my blog it takes some seconds delay for respond..like 5 or 6+ seconds!
But thanks it working, I’m happy now :D
Thanks again bro.
My problem was from AddToAny plugin, After deactivate working like a charm, Thanks so much brother.
I’m glad you’ve figured it out! 🙃
Testing this great ajax comment!
Hola de España
Great Article it its really informative and innovative keep us posted with new updates. its was really valuable. thanks a lot.
Great article!
Super useful! Thanks so much dude, saves me a headache or two.
Seems like
ajax.complete
will also show if errors are present. Try includingTest
and it will show when you try to submit the form with errors.Any ideas on how to check if a comment is actually successfully submitted?
I meant try including a test html text block in the
ajax.complete
and it will show up. The formatting in the comment above failed.Alright, I figured it out. It was actually pretty simple, and I was probably overthinking it. Just leaving this here in case anyone finds it useful. Also, Misha, probably has a cleaner way of doing this lol.
I pass
data
in theajax.complete
and simply check if theresponseText
includes the start of the actual comment html (if there are comments present, there won’t be any comment HTMl from Step 4).Thank you for your comment, Chris!
Great! Let me check this…
Great post!
Not sure if this is the best way to make comment ajaxable..
Simple only need JS, future proof (not hard code the comment post process) – you can try this
thanks for sharing this information this is too helpful for me Comment Submission Without Page Refresh. No Plugins Used is also a great idea.
Hi Misha, sorry that previous “Testing” was me.
The AJAX here is impressive, but I actually have a real question.
I’m thinking, would it be possible to use WP commenting section as a private chat? Meaning, that you’d only see conversation between yourself (if registered and logged in) and the current post/page author?
Hi,
Yes, I think.
You just have to check what comments to display. So, for a regular user we have to display his/her own comments and administrator comments.
And here we go. great ajax comment system!
hello my friend
i wat this amazing code for wordpress 5.x to up .
its not working for me :/
Good comment system!
Sorry, it is not AJAX at this time but I’m going to return it soon!
Good comment system!