Contactez-nous

require([ 'VladimirPopov_WebForms/js/form', 'jquery', 'VladimirPopov_WebForms/js/sweetalert', 'jquery/jquery.cookie' ], function (VarienForm,jQuery,swal) { var blockId = 'webform_6mapHX'; var jblockId = '#' + blockId; var webform_6mapHX = new VarienForm(blockId, 0); // Ajax submit jQuery('body').on('click', jblockId +' .action.submit', function(e) { var form = webform_6mapHX; if(typeof tinyMCE === 'object') tinyMCE.triggerSave(); if (!(form.validator && form.validator.validate())) { return; } var formData = new FormData(jQuery(jblockId)[0]); var self = this; e.preventDefault(); e.stopImmediatePropagation(); jQuery.ajax({ url: 'https://www.bipackfrance.fr/webforms/form/submit/', data: formData, type: 'POST', cache: false, dataType: 'json', contentType: false, processData: false, beforeSend: function () { self.disable(); $(blockId + '_sending_data').show(); }, success: function (data, status, xhr) { if (data.success > 0) { if (data.script) { eval(data.script); return; } if (data.redirect_url) { $(blockId + '_progress_text').update('Redirecting'); // decode html entities window.location = jQuery('
').html(data.redirect_url).text(); return; } var successText = data.success_text; $(blockId + '_progress_text').update('Terminée'); Effect.Fade(blockId + '_form', { duration: 0.5, from: 1, to: 0, afterFinish: function () { $(blockId + '_success_text').update(successText).show(); Effect.Fade(blockId + '_success_text', { duration: 0.5, from: 0, to: 1 }); if (1) Effect.ScrollTo(blockId + '_success_text',{duration:'0.1', offset:-window.innerHeight/2}); } }); } else { $(blockId + '_submit_button').enable(); if ($(blockId + '_sending_data')) $(blockId + '_sending_data').hide(); if ($(blockId + '_submit_button')) $(blockId + '_submit_button').enable(); var errorTxt = ''; if (data.errors && typeof(data.errors) == "string") { errorTxt = data.errors.unescapeHTML(); } else { errorTxt = 'Unknown error(s) occured'; } swal.fire({ title: 'Erreur', html: errorTxt, type: 'error' }); if (data.script) { eval(data.script); } } }, error: function (xhr, status, errorThrown) { console.log('Error happens. Try again.'); console.log(errorThrown); } }); }); });