jquery not firing after form submit with ajax

jquery not firing after form submit with ajax

Hi,
The code below works GREAT on form page load and typing into "test_field". The number of characters left display correctly in " display_char_left"

So all is good until AFTER the form is submitted. After saving the form, ajax is used to refresh page (save data) and display form again with the same field data. Now, the countChar() is never fired again. 

How do you make the countChar function continue to execute/work AFTER saving the form, when ajax is used to refresh the page? thanks

  1. <script>
  2.   var maxLength = 40;
  3. function countChar() {
  4.   var length = $('#test_field').val().length;
  5.   length = maxLength-length;
  6.   jQuery('#display_char_left').text(length);
  7. };

  8.  
  9. jQuery(document).ready(function($) {
  10. $("#test_field").on('load', function() {
  11.    countChar(); });
  12. $("#test_field").on('propertychange', function() {
  13.    countChar(); });
  14. $("#test_field").on('keyup', function() {
  15.    countChar(); });
  16. $("#test_field").on('input', function() {
  17.    countChar(); });
  18. $("#test_field").on('paste', function() {
  19.    countChar(); });
  20.   
  21.   countChar();
  22. });
  23. </script>