Forums

Contact Form 7
Allow AJAX after Submit (2 posts)

  1. zaus
    Member
    Posted 2 years ago #

    Contact Form 7 v 2.4.3
    Currently, Contact Form 7 clears the form values after submission. However, it clears these values before performing the on_sent_ok action, which I would like to use to perform an AJAX POST to a different form/file/whatever.

    Just wanted to share the fix -- patch follows.

    Index: scripts.js
    ===================================================================
    --- scripts.js	(revision 36238)
    +++ scripts.js	(revision 36239)
    @@ -42,11 +42,14 @@
     						ro.addClass('wpcf7-spam-blocked');
    
     					if (1 == data.mailSent) {
    -						$(data.into).find('form').resetForm().clearForm();
     						ro.addClass('wpcf7-mail-sent-ok');
    
     						if (data.onSentOk)
     							$.each(data.onSentOk, function(i, n) { eval(n) });
    +
    +						//moving after onsent to preserve form values
    +						$(data.into).find('form').resetForm().clearForm();
    +
     					} else {
     						ro.addClass('wpcf7-mail-sent-ng');
     					}
  2. 3r1c
    Member
    Posted 2 years ago #

    Awesome! Exactly what I was looking for. Thanks!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic