Title: Own javascript not working after posting a comment
Last modified: August 21, 2016

---

# Own javascript not working after posting a comment

 *  Resolved [localhost_8080](https://wordpress.org/support/users/localhost_8080/)
 * (@localhost_8080)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/own-javascript-not-working-after-posting-a-comment/)
 * Hi there,
 * Love your plugin and it’s beautifully designed.
 * It works very well. I guess it’s my problem.
    I added a custom field in the comment
   form, along with some javascript codes. Before posting a comment, everything 
   works properly. After posting a comment, the new comment was successfully posted
   and showed on the page, but my own javascript codes were all dead. Is it because
   I add the javascript code in window.addEventListener(‘load’, function() {} ) ?
   If so, where should I place my code?
 * Sorry to bother you if this has nothing to do with your plugin.
    Thank you for
   delivering this useful plugin.
 * [http://wordpress.org/plugins/wp-ajaxify-comments/](http://wordpress.org/plugins/wp-ajaxify-comments/)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Thread Starter [localhost_8080](https://wordpress.org/support/users/localhost_8080/)
 * (@localhost_8080)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/own-javascript-not-working-after-posting-a-comment/#post-4125134)
 * I added the following code in the end of formSubmitHandler:
 *     ```
       jQuery(function($) {
           $.getScript('External_JS_File_Path.js', function() {});
       });
       ```
   
 * it somehow worked. Not sure if it is an acceptable solution.
 *  [janjonas](https://wordpress.org/support/users/janjonas/)
 * (@janjonas)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/own-javascript-not-working-after-posting-a-comment/#post-4125212)
 * Hi localhost_8080,
 * you can use the “onAfterUpdateComments” callback option to add your own JavaScript
   code that should be executed after the comments have been replaced.
 * Hope this helps…
    Jan
 *  Thread Starter [localhost_8080](https://wordpress.org/support/users/localhost_8080/)
 * (@localhost_8080)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/own-javascript-not-working-after-posting-a-comment/#post-4125213)
 * Hi Jan,
 * I moved the code to “onAfterUpdateComments” callback, and it works. A big thank
   you from Beijing 🙂
 *  [janjonas](https://wordpress.org/support/users/janjonas/)
 * (@janjonas)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/own-javascript-not-working-after-posting-a-comment/#post-4125249)
 * Thanks for your feedback.
 * Please think about supporting the plugin by making a small donation or writing
   a short review.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Own javascript not working after posting a comment’ is closed to new 
replies.

 * ![](https://ps.w.org/wp-ajaxify-comments/assets/icon-256x256.png?rev=2962290)
 * [Ajaxify Comments - Ajax and Lazy Loading Comments](https://wordpress.org/plugins/wp-ajaxify-comments/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-ajaxify-comments/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-ajaxify-comments/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-ajaxify-comments/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-ajaxify-comments/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-ajaxify-comments/reviews/)

## Tags

 * [ajax](https://wordpress.org/support/topic-tag/ajax/)
 * [comment_form](https://wordpress.org/support/topic-tag/comment_form/)
 * [javascript](https://wordpress.org/support/topic-tag/javascript/)

 * 4 replies
 * 2 participants
 * Last reply from: [janjonas](https://wordpress.org/support/users/janjonas/)
 * Last activity: [12 years, 8 months ago](https://wordpress.org/support/topic/own-javascript-not-working-after-posting-a-comment/#post-4125249)
 * Status: resolved