Title: Two JavaScript-Bugs in Version 1.4
Last modified: August 30, 2016

---

# Two JavaScript-Bugs in Version 1.4

 *  [Jan Teriete](https://wordpress.org/support/users/leisurelarry/)
 * (@leisurelarry)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/two-javascript-bugs-in-version-14/)
 * If you send the cleverreach form without filling the mail field. It’ll be send
   using Ajax. Now filling or not filling the field, the form is send without using
   Ajax.
 * Fixing this I noticed that on Ajax post the wrong element is replaced. You’re
   only replacing the form which’ll leave the error message.
 *     ```
       var haet_cleverreach = haet_cleverreach || {};
   
       jQuery(document).ready(function($) {
           $(document).on('submit', '.haet-cleverreach-form', function() {
               var $form = $(this);
               var submission = {};
               $form.find('.cleverreach-loader').slideDown(400);
               $form.find('[name]').each(function(){
                   var $field = $(this);
                   submission[$field.attr('name')] = $field.val();
               })
   
               var data = {
                   'action': 'cleverreach_submit',
                   'submission': submission
               };
   
               $.post(ajax_object.ajax_url, data, function (response) {
                   $form.closest('.haet-cleverreach').replaceWith(response);
               });
   
               return false;
           });
       });
       ```
   
 * As you see I’m using a live event handler which isn’t deleted on replacing the
   form. Besides I’m using closest to get the necessary parent element.
 * Greats from Germany
    Jan
 * [https://wordpress.org/plugins/cleverreach/](https://wordpress.org/plugins/cleverreach/)

The topic ‘Two JavaScript-Bugs in Version 1.4’ is closed to new replies.

 * ![](https://ps.w.org/cleverreach/assets/icon-256x256.png?rev=2758102)
 * [Newsletter Sign-Up for CleverReach](https://wordpress.org/plugins/cleverreach/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cleverreach/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cleverreach/)
 * [Active Topics](https://wordpress.org/support/plugin/cleverreach/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cleverreach/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cleverreach/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [Jan Teriete](https://wordpress.org/support/users/leisurelarry/)
 * Last activity: [10 years, 9 months ago](https://wordpress.org/support/topic/two-javascript-bugs-in-version-14/)
 * Status: not resolved