Title: HTML Message responses
Last modified: August 28, 2020

---

# HTML Message responses

 *  [iuvabo](https://wordpress.org/support/users/iuvabo/)
 * (@iuvabo)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/html-message-responses/)
 * Hi,
    I’m using your plugin with a gpdr cookie plugin with cf7 and active recapcha3.
   When a user denies using third-party cookies (googles reCaptcha) and uses the
   contact form the server response is:
 *     ```
       {
       into: "#wpcf7-f608-p826-o2"
       message: "<div class="cmplz-blocked-content-notice cmplz-accept-cookies"><a href="#">Click here to accept marketing cookie and enable this form</a></div>"
       posted_data_hash: ""
       status: "spam"
       }
       ```
   
 * There are two issues: SWAL shows success with the messagetext in html.
 * I fixed this with this code (changed to html output) in file addon-sweetalert-
   contact-form-7.php:
 *     ```
       var validMessage = function() {
          Swal.fire({
          icon: "success",
          title: "<?php echo esc_attr(strtoupper($title_success)); ?>",
          html: message,
          timer: <?php if (empty($duration_success)) {
             echo '3000';
          } else {
             echo esc_attr($duration_success);
          } ?>,
          showConfirmButton: false
          });
       };
       var errorMessage = function() {
          Swal.fire({
             icon: "warning",
             title: "<?php echo esc_attr(strtoupper($title_error)); ?>",
             html: message,
             timer: <?php if (empty($duration_error)) {
             echo '3000';
          } else {
             echo esc_attr($duration_error);
          } ?>,
          showConfirmButton: false
          });
       };
       ```
   
 * Then I changed code around line 95:
    `$(document).ajaxComplete(function(event,
   xhr) {` to get the xhr response and use it additional around line 124:
 *     ```
       setSwal = $("form.wpcf7-form").hasClass("invalid") ? "alert" : "success";
       if (typeof xhr.responseJSON !== "undefined" && typeof xhr.responseJSON.status !== "undefined") {
          switch (xhr.responseJSON.status) {
             case "validation_failed":
             case "spam":
                setSwal = "alert"
             break;
             case "success":
             setSwal = "success"
             break;
          }
       }
       ```
   
 * Don’t know if this is a suitable solution, but it works. Maybe you want to use
   it in the plugin
    -  This topic was modified 5 years, 9 months ago by [iuvabo](https://wordpress.org/support/users/iuvabo/).
    -  This topic was modified 5 years, 9 months ago by [iuvabo](https://wordpress.org/support/users/iuvabo/).
      Reason: Formatting

The topic ‘HTML Message responses’ is closed to new replies.

 * ![](https://ps.w.org/addon-sweetalert-contact-form-7/assets/icon-256x256.png?
   rev=2279783)
 * [Add-on SweetAlert Contact Form 7](https://wordpress.org/plugins/addon-sweetalert-contact-form-7/)
 * [Support Threads](https://wordpress.org/support/plugin/addon-sweetalert-contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/addon-sweetalert-contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/addon-sweetalert-contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/addon-sweetalert-contact-form-7/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [iuvabo](https://wordpress.org/support/users/iuvabo/)
 * Last activity: [5 years, 9 months ago](https://wordpress.org/support/topic/html-message-responses/)
 * Status: not resolved