WordPress Plugin: iF AJAX Comments

Current version

0.99.2 (August 5, 2008) • Download

Description

AJAX enabled commenting based on the jQuery framework. This plugin will hook into the comments form and posts the user comment without reloading the whole page. Many configuration options trough the settings page which can be found at ‘Settings -> AJAX Comments’.

Installation

  1. Upload the full directory into your wp-content/plugins directory
  2. Activate it in the Plugin options
  3. Open the settings page at Settings -> AJAX Comments to set the default options (initial options are set automatic) or further customize the look & feel of the plugin.
  4. Happy commenting!

Frequently Asked Questions

  • I’ve tried everything, the plugin does not work. What should I do?
    • Try the plugin with the ‘default’ theme. If it works, your theme is missing one or more of the following tags:
    • <ol class=”commentlist”>
    • <h3 id=”respond”>
    • <form id=”commentform”>
    • <textarea id=”comment”>
    • pay attention to the id & class names
  • I’ve tried to run the plugin with the ‘default’ theme, still no luck. What’s next?
    • Do you have other plugins activated? Try to deactivate another plugin, and run the test again. If my plugin works after deactivating a certain plugin, you have just found an incompatability between my plugin and the one you deactivated. Please inform me about this, thanks!
  • Tried with the ‘default’ theme and deactivated all other plugins. Still doesn’t work. What now?
    • Please post a comment or contact me. Include a link to your website on which my plugin is not working. Please leave my plugin activated. I will have a look at it and inform you about the next steps. Thanks.

Bug reporting

If you find any bugs PLEASE leave a comment with a description so I can fix them!

Modify / Customize

Since I’ve been asked many times on how to modify certain things in this plugin, I’ll give a quick example. Here we change the appearance of the error message :

The error messages are handled in ‘/js/if-ajax-comments.js’ at line 144 - 150 :

144
145
146
147
148
149
150
if(xError != '')
{
    jQuery('#'+css_commentform).before('<div id="msgError" class="msgError"></div>');
    jQuery('#msgError').html(xError).show().fadeOut(300).fadeIn().fadeOut(4000);
    xError = '';
    return false;
}

On line 126 two things happens:

  1. the script is looking for the ID ‘#commentform’ and
  2. injects a new DIV (the error message) before the ‘#commentform’.

Say, for example, we want the error message to be shown after the comment form, we change the line into this :

146
jQuery('#'+css_commentform).after('<div id="msgError" class="msgError"></div>');

If we want the error message to be shown on top of ‘LEAVE A REPLY’, we would change the line to :

146
jQuery('h3#respond').before('<div id="msgError" class="msgError"></div>');');

It’s pretty simple and you can do almost anything you want. Just keep in mind : whenever I update the plugin and put a new version to the repository at WordPress, your changes will be overwritten!

More information about jQuery

Contributors, Bug finders & helpers

Thanks to all testers & commenters, your feedback is much appreciated!

  • Digg
  • del.icio.us
  • Facebook
  • Google
  • E-mail this story to a friend!
  • Live
  • Slashdot
  • StumbleUpon
  • Technorati
  • TwitThis

188 Responses to “WordPress Plugin: iF AJAX Comments”

  1. Wo! i think i will use it =) Tnx!!, I’ll will coment back after tests.

  2. Francisco

    Thank you very much for sharing your Plugin!

  3. You’re all much welcome, enjoy!

  4. hi. Thanks for plugin

    perfect.

    Regards

  5. saku

    hmm.. I wonder what its like…

  6. I am using it on my site, but, it shows the loading image, the page only shows the loading image and not the comment. But, if i do a hard refresh the comment is shown!

  7. Also is it possible to show the comment form after a user posts his comment. I don’t have a comment editor installed, so there are times when readers need to post a comment immediately after their previous one.

  8. @Manan

    Q : ‘the page only shows the loading image’
    A : Please check the CSS ID’s & Classes

    Q : ‘is it possible to show the comment form after a user posts his comment’
    A : Please update the plugin. I have added the option to the settings page.

  9. The id is commentform & the ol class is commentlist :(

  10. Sorry it won’t work for my particular installation. The 0.93 version doesn’t display in the Settings list in WP 2.5.1. I can access it by clicking the link in the Plugins page.

    Worse, when I check a particular progress bar/wheel option, it remains unchecked. When I post a message, it just hangs.

    Yes, maybe there’s a conflicting plugin, but I wouldn’t necessarily know where I should start.

    Peace,
    Gene Steinberg

  11. Freddy

    I got a problem too. After clicking the submit button, it shows the message (generating comment…) but no “loading image”, and the page doesn’t load. I already edited the CSS classes.

  12. Looks interesting!

  13. doesn’t seem to show ‘thank you’ message.. Stays stuck on ‘adding comment’..

    tried on my test blog http://www.locksleynet.com/testa

    Would be ace otherwise, I know its in early stages so I’ll be patient ;-)

  14. Hello everybody

    First, thanks for the feedback. It’s much appreciated!

    I have noted all bugs & problems here. I will make further tests with the plugin & fix bugs much as I can.

    For those with the ‘message stuck’: does the site load Scriptaculous?

    Again, thanks!

  15. ok, that seems pretty cool!

  16. I never heard of that. Is it a plugin or what?

    Peace,
    Gene

  17. But what does that have to do with “Scriptaculous?”

    Peace,
    Gene

  18. Franzi

  19. Update:

    I confirm that the plugin have problems (not work) when the Scriptaculous framework is loaded.

    Right now I’m rewriting the plugin to use jQuery. First tests confirmed that with the plugin runs fine even if other frameworks are loaded.

    Give me two days, and I’ll give you the next release…

    Thanks!

  20. Bruno

  21. Thanks a lot for taking note. I hope the issues will resolve asap. Thanks for time again. Appreciate it :)

  22. I look forward to trying your new version. It sounds hopeful.

    Peace,
    Gene

  23. thanks for the plugin i hope to put it to good use.

    how about modifying it to use the google ajax libraries ? @

    http://code.google.com/apis/ajaxlibs/documentation/index.html#mootools

    if the plugins used on a number of sites, it would help load times and take load off of the users sites.

    the same can be done with the jquery port.

    Thanks again for the plugin.

  24. Update:

    I have ported the plugin to jQuery, please update…
    ;-)

  25. great plugin, thank you very much for your work - i will sure install it this week.

    have a nice week

    sara

  26. Hero

    Howdy!

    Thanks for this great plugin!

  27. Sorry, folks, it just doesn’t work. Preferences take, but it does nothing otherwise.

    I tried disabling another comment-related plugin, WP-Ajax Edit Comments, but no change.

    I also just installed WP 2.6b1, so maybe that’s at fault?

    Peace,
    Gene

  28. In fact, it doesn’t seem to even work here. When I posted the above comment, the page refreshed normally — no evidence of Ajax anywhere.

    Peace,
    Gene

  29. Again - Update:

    There where 2 bugs, a typo and the fact that not all hosting servers have php 5.2 installed which prevented json_encode from working.

    I have now updated everything and it should run just fine.

    Thanks & enjoy!!!

  30. @Chris

    Thanks for the input. I will have a look at it.
    ;-)

  31. Yeah, better, much better :)
    Peace,
    Gene

  32. OK, just a minor issue. I also use WP-Ajax Edit Comments, and when a comment is posted, that plugin’s edit fields vanish unless you refresh the page. I suppose you and the author of that plugin should have a pleasant talk and see if you can work nicely together. Other than this minor issue, is is the first Ajax comment plugin that’s ever worked for me, and I’ve tried lots of them.

    Peace,
    Gene

  33. on a le droit de tester en fran

  34. @Gene :

    Glad it finally worked for you. I really appreciate comments like ‘it is the first plugin that’s ever worked for me, and I’ve tried lots of them…’!

    Regarding the ‘WP-Ajax Edit Comments’ conflict : I’ll download that plugin and have a look at it.
    ;-)

  35. I mentioned to the author of the other plugin about this too.

  36. Another problem :( The comment is published but is not shown. As in it says that the comment has been published, the comment form re-appears, but the comment does not :?

  37. @Manan

    Please give me a link so I can check it out, thanks. (eMail)

  38. My name is the link, however, I have sent you a mail too.

  39. @Manan

    Your comments template (comments.php) is missing the id="respond" in the <h3> tag. Replied to your mail as well.

  40. vsy

    hi, i tried this plugin on my localhost, and i use chinese to write comment, but when i submit the comment, chinese will be wrong text.

    like this “%u54C8%u56C9″
    will be a wrong text “%u54C8%u56C9″

    thx.

  41. vsy

    ok…like my last comment.
    you can copy any chinese at chinese wikito test the bug. :)

  42. Ok, should be fixed (posted with AJAX) :

    一 二 三 四 五 六 七 八 九 十

  43. vsy

    Thanks you to take my opinion. :)

  44. Looks Great

    Looks like it works great :)

  45. I have been using this plugin for a couple of days, initially had some issues, which were promptly rectified and to be honest, I love this plugin. Thanks a ton. Amazing work!

  46. Johan

    First of all, great and easy plugin! How ever I would like to move the error massages to be on top of the form (preferable) or below the form. How would I do that?

  47. @Johan

    Thanks for your feedback!

    I updated the post, it contains now a ‘Modify / Customize’ section. Please have a look at the example. If you have any more questions, feel free to ask them here.

  48. @vsy
    I had a same chinese word bug

  49. Johan

    Great with some easy modifications! When I wrote “on top of the form” I actually meant overlaying the form, ie in a with a higher z. is that possible? Also I have a problem with the Swedish chars, a with a dot over it and o with two dots over it. Will that be supported in 0.96?

  50. Y

    I’ve been looking for a plugin like this for ages, and am thrilled to have found yours. Have installed it, but it doesn’t seem to be working for me like I expected. I tested it on my page and after commenting, the comment appears but the comment is also still in the comment box. Also got someone else to try commenting on my page and he said, “I posted and it didn’t tell me anything. Then I tried to post the
    same thing again, and it told me I’d already posted that. “

  51. @Johan

    Yes, release 0.96 (which is available) *should* support Swedish (Unicode) chars (and this also depends on your WordPress installation, see known issues above). Why don’t you try to post something in Swedish here? ;-)
    To create a overlay DIV is possible. You could also use a Thickbox overlay for that.

  52. @Y

    Just wanted to test the plugin at your site but i don’t see it activated. Please activate it or provide me a link, thanks.

  53. Y

    Hi. I’ve reactivated the plugin. Can I also add that I have no other plugin activated except for the Akismet 2.1.6, so can’t imagine that there might be a conflict happening somewhere..

    Try commenting on any post. eg. http://blog.lemonpi.net/?p=1729

  54. OK, let’s try this plugin :-)

  55. @Y

    OK, two things:

    1. set the path variable as described above in the ‘Notes’. In your case that would be: ‘http://lemonpi.net/blog/wp-content/plugins/if-ajax-comments-for-wordpress/’

    2. change the CSS ID ‘respond’ to ‘postcomment’ in the settings page

    That should do the trick…

  56. Johan

    Ok, here is some Swedish chars, I didn’t dare to write them before because then the post became empty :) Beware: å, å, ö and maybe an é to finish of with.

  57. @Y

    And I just saw something more. The plugin tries to load its variables from another domain (http://lemonpi.net/blog/) which is not possible due to security restrictions (cross-domain).

    There is nothing I can do about this, you should talk with your hoster or better set up your blog in a subdirectory, not a subdomain.

    Good Luck!

  58. Y

    Ah thanks. I’ve just been trying to follow your previous suggestions and was trying to nut out why it still wasn’t working.

  59. Hey Pete, I just wanted to clear a small doubt which I guess only you can help me out with. Does using Ajax Commenting suck a lot of bandwidth?

  60. Excellent! Works great now :)

  61. @Manan

    One of the reasons for me to build this plugin is that it actually SAVES you bandwidth! Loading the plugin (settings < 1 kb), posting (~2 kb) and retrieving (~2 kb, depends how much the commenter writes) a comment is still < 10 kb. Lots of data is being cached anyway, so it's even less.

    Now imagine posting and retrieving the whole page every time a visitor posts a comment on your site (your latest post: > 50 kb).

    You decide…

    ;)

  62. @Pete: Thanks for the reply,actually some bloggers told me that they aren’t using Ajax Commenting coz it sucks bandwidth so I thought who better to ask than the creator himself :D
    BUG ALERT: The plugin seems to have some issues with the Subscribe to Comments plugin. Even after un-subscribing here, I do get emails, a few readers on my blog too said that they are receiving mails even though they un-checked the Subscription box before commenting.

  63. @Manan

    Regarding the subscriptions you cannot unsubscribe just by unchecking the field. If you have previously subscribed to receive a comment thread and wish to unsubscribe, you do that in the subscription manager. When subscribed, instead of the checkbox there is a link at the bottom : ‘You are subscribed to this entry. Manage your subscriptions.’

    Click on ‘Manage your subscriptions’, this will bring you to the manager where you can unsubscribe…

    HTH

    PS: if you don’t see the link then you have obviously deleted the cookies. I this case, you need to tell the webmaster/admin to remove you from the list.

    ;)

  64. @Pete: Yeah, I know about that and that’s what I have done multiple times on this topic, but I still get the email and so do my readers. When they reply to a new topic for the first time, they un-check the box (as it remembers the previous state) but they still get the notifications for that topic.

  65. @Manan

    Confirm: this was a bug in my plugin. Already uploaded fixed release, please update the plugin & clear the browser cache. Thanks for pointing this out!

    ;)

  66. Works with wp-cache enabled? Thx!

  67. @Skeku

    I have tested it locally with ‘wp-super-cache‘ enabled (default options) and the plugin does work.

    HTH

  68. It seems the plugin is not compatible with Markdown extra plugin (http://www.michelf.com/projects/php-markdown/). When I try to use code from Markdown, I’ve got an error.

  69. Oh, it works very well here :-) With WP Ajax edit comments plugin, I have two comments showing before reloading the page.

  70. @Li-An

    The plugin works well together with Markdown Extra (it’s installed here, you can try it). This plugin currently doesn’t work well together with the ‘WP Ajax edit comments’ plugin, this has been stated in the known issues.

    HTH

  71. Thank you for this precision. So I have two options: use this plugin or the WP Ajax edit plugin :-)

  72. @Li-An

    For now, yes, that would be the two options. I will make my plugin compatible with WP AJAX Edit Comments in a future release.

    HTH ;)

  73. I’m waiting for this release :-) I like the idea of ajaxed comments.

  74. The plugin is now ‘WP AJAX Edit Comments’ compatible. Please update.

    ;)

  75. OK, just a further suggestion. :)

    How about retaining settings between installations rather than having to go into the Settings panel every time there’s an update?

    Peace,
    Gene

  76. I made a test and it works strange. As admin I’ve got two comments showing and as guest I’ve got one comment for each other comments showing before I reload :-( Don’t know where it could come from. Maybe some other people have the same problem.

  77. @Gene
    Yes, you are absolutely right. It wont happen again on the next update, promise! ;)

    @Li-An
    I had a look at your site. The problem comes from the ‘Arthemia’ theme (file comments.php, to be precise). There is a DIV which is not correctly closed and contains the same CSS class definition as the parent UL. Solution : delete the line 32 in the file ‘wp-content-/themes/arthemia/comments.php’

    Line 32 looks like this:

    32
    
    <div class="commentlist">

    HTH ;)

  78. Thank you for pointing this. I will take a look on it.