There is a website on which the callback form is located. Upon successful completion of the fields, the form is sent as expected, but the notification is not shown as we would like. When you click on the "Send" button, the window is closed with ajax (if I understand correctly) and a small green sign is shown with gratitude. Tell me how to implement it instead: when you click on the "Send" button, it redirects to a separate page, where I will expand more beautiful thanks. I am not strong in PHP, wrote in those who support this topic, they said that it is necessary to change in this file on line 107 (I attach all the code from this file).

(function($) { $(document).ready(function () { inquiry.init(); }); var inquiry = { init: function () { $('.contact-' + window.postType).on('click', function(event) { inquiry.showInquiryForm(); event.preventDefault(); }); $('.cancel-' + window.postType + '-inquiry').on('click', function(event) { inquiry.hideInquiryForm(); event.preventDefault(); }); $('.' + window.postType + '-inquiry-form').validate({ onkeyup: false, ignore: [], invalidHandler: function(e, validator) { var errors = validator.numberOfInvalids(); if (errors) { var message = errors == 1 ? window.formSingleError : window.formMultipleError.format(errors); $("div.error div p").html(message); $("div.error").show(); } else { $("div.error").hide(); } }, submitHandler: function() { inquiry.processInquiry(); } }); $.each(window.inquiryFormFields, function(index, field) { if (field.hide !== '1') { var $input = null; if (field.type == 'text' || field.type == 'email') { $input = $('.' + window.postType + '-inquiry-form').find('input[name=' + field.id + ']'); } else if (field.type == 'textarea') { $input = $('.' + window.postType + '-inquiry-form').find('textarea[name=' + field.id + ']'); } if ($input !== null && typeof($input) !== 'undefined') { if (field.required == '1') { $input.rules('add', { required: true, messages: { required: window.inquiryFormRequiredError } }); } if (field.type == 'email') { $input.rules('add', { email: true, messages: { required: window.inquiryFormEmailError } }); } } } }); }, showInquiryForm : function () { $('.three-fourth').hide(); $('.right-sidebar').hide(); $('.full-width.' + window.postType + '-inquiry-section').show(); }, hideInquiryForm : function () { $('.three-fourth').show(); $('.right-sidebar').show(); $('.full-width.' + window.postType + '-inquiry-section').hide(); }, processInquiry : function () { var cValS = $('#c_val_s_inq').val(); var cVal1 = $('#c_val_1_inq').val(); var cVal2 = $('#c_val_2_inq').val(); var dataObj = { 'action':'inquiry_ajax_request', 'userId' : window.currentUserId, 'postId' : window.postId, 'c_val_s' : cValS, 'c_val_1' : cVal1, 'c_val_2' : cVal2, 'nonce' : BYTAjax.nonce }; $.each(window.inquiryFormFields, function(index, field) { if (field.hide !== '1') { dataObj[field.id] = $('#' + field.id).val(); } }); $.ajax({ url: BYTAjax.ajaxurl, data: dataObj, success:function(data) { if (data == 'captcha_error') { $("div.error div p").html(window.InvalidCaptchaMessage); $("div.error").show(); } else { $("div.error div p").html(''); $("div.error").hide(); $('.contact-' + window.postType).hide(); // hide the button inquiry.hideInquiryForm(); $('.inquiry-form-thank-you').show(); } }, error: function(errorThrown) { } }); } }; })(jQuery); 

    2 answers 2

    this is (106 - 110 line)

     $("div.error div p").html(''); $("div.error").hide(); $('.contact-' + window.postType).hide(); // hide the button inquiry.hideInquiryForm(); $('.inquiry-form-thank-you').show(); 

    replace with (JQUERY syntax)

     $(location).attr('href', 'http://google.com'); 

    or on (Native JS syntax)

     document.location = 'http://google.com'; 

    Where http://google.com is the full path to your page.

    or replace with (JQUERY syntax)

     $(location).attr('href', 'other_page.php'); 

    or on (Native JS syntax)

     document.location = 'other_page.php'; 

    Where other_page.php is a relative path (other_page.php is in the same folder as the script)

    • I apologize, but in my opinion using jquery for redirection is brute force, stackoverflow.com/a/506004/4222611 - olegatro
    • one
      if the code is already written in JQUERY, then writing code in the same style cannot be brute force - Lesiuk Alexey

    You can simply after 111 lines:

     $('.inquiry-form-thank-you').show(); 

    add redirect via javascript:

     document.location.href = 'http://адрес_для_перенаправления'; 
    • Added and did not help, does not open a new page. - Valery Emelyanov
    • @Valery Emelyanov, because javascript needs to be output like this: echo "<script> document.location.href = 'http://адрес_для_перенаправления';</script>" - Telion
    • @Levelleor All exactly does not open a new page. - Valery Emelyanov
    • @ Valery Yemelyanov site available from the network? post a link. - olegatro
    • @Olegatro sunnyge.com/hotel/gostevoj-dom-anakliya - Valery Emelyanov