Jump to content

arseniyivanov

Neophyte
  • Posts

    1
  • Joined

  • Last visited

arseniyivanov's Achievements

Explorer

Explorer (1/14)

0

Reputation

  1. Доброй ночи! Возможно не совсем по той же теме, но мой вопрос упирается в те же корни. Пытаюсь из формы подписки "subscribe" сделать форму отправки номера телефона на мой почтовый адрес, но от этих танцев с бубном голова напрочь отваливается, мучительно-долго бьюсь..... может кто сможет предложить способ решения задачи? был бы очень признателен за помощь, начинающему. <!-- Email Subscription Section --> <section class="sub_box" id="order"> <p class="cta_text animated wow fadeInDown">ФОРМА ЗАЯВОК</p> <form action="mailto:a-r-s@mail.ru" method="post" class="animated wow fadeIn" data-wow-duration="2s" id="submit_form"> <input type="email" id="mc-email" placeholder="Оставьте свой номер, мы перезвоним"/> <button type="submit" id="mc_submit"> <i class="icon"></i> </button> </form> <div class="message" id="error_msg">Введите правильный номер.</div> <div class="message" id="success_msg">Ваша заявка принята.</div> </section> <!-- End Email Subscription Section -->и​ обнаружил, что к данной форме привязаны два ява скрипта 1. ajaxchimp.js (function($){"use strict";$.ajaxChimp={responses:{"We have sent you a confirmation email":0,"Please enter a value":1,"An email address must contain a single @":2,"The domain portion of the email address is invalid (the portion after the @: )":3,"The username portion of the email address is invalid (the portion before the @: )":4,"This email address looks fake or invalid. Please enter a real email address":5},translations:{en:null},init:function(selector,options){$(selector).ajaxChimp(options)}};$.fn.ajaxChimp=function(options){$(this).each(function(i,elem){var form=$(elem);var email=form.find("input[type=email]");var label=form.find("label[for="+email.attr("id")+"]");var settings=$.extend({url:form.attr("action"),language:"en"},options);var url=settings.url.replace("/post?","/post-json?").concat("&c=?");form.attr("novalidate","true");email.attr("name","EMAIL");form.submit(function(){var msg;function successCallback(resp){if(resp.result==="success"){msg="We have sent you a confirmation email";label.removeClass("error").addClass("valid");email.removeClass("error").addClass("valid")}else{email.removeClass("valid").addClass("error");label.removeClass("valid").addClass("error");var index=-1;try{var parts=resp.msg.split(" - ",2);if(parts[1]===undefined){msg=resp.msg}else{var i=parseInt(parts[0],10);if(i.toString()===parts[0]){index=parts[0];msg=parts[1]}else{index=-1;msg=resp.msg}}}catch(e){index=-1;msg=resp.msg}}if(settings.language!=="en"&&$.ajaxChimp.responses[msg]!==undefined&&$.ajaxChimp.translations&&$.ajaxChimp.translations[settings.language]&&$.ajaxChimp.translations[settings.language][$.ajaxChimp.responses[msg]]){msg=$.ajaxChimp.translations[settings.language][$.ajaxChimp.responses[msg]]}label.html(msg);label.show(2e3);if(settings.callback){settings.callback(resp)}}var data={};var dataArray=form.serializeArray();$.each(dataArray,function(index,item){data[item.name]=item.value});$.ajax({url:url,data:data,success:successCallback,dataType:"jsonp",error:function(resp,text){console.log("mailchimp ajax submit error: "+text)}});var submitMsg="Submitting...";if(settings.language!=="en"&&$.ajaxChimp.translations&&$.ajaxChimp.translations[settings.language]&&$.ajaxChimp.translations[settings.language]["submit"]){submitMsg=$.ajaxChimp.translations[settings.language]["submit"]}label.html(submitMsg).show(2e3);return false})});return this}})(jQuery);2. main.js //Mailchimp subscription form initialization $('#submit_form').submit(function(){ $('#mc_submit').attr('disabled', 'disabled'); processing('icon', 'loading'); }); if($('#submit_form').length){ //Mailchim Subscription form $('#submit_form').ajaxChimp({ callback: chimpResponce }); } //Mail chimp callback function function chimpResponce(resp) { if (resp.result === 'success') { processing('loading', 'icon'); $('#mc_submit').removeAttr('disabled', 'disabled'); $('#submit_form #mc-email').val(''); $('#error_msg').hide(); $('#success_msg').show(); }else{ processing('loading', 'icon'); $('#success_msg').hide(); $('#error_msg').show(); $('#mc_submit').removeAttr('disabled', 'disabled'); } } function processing(hide, show){ $('#mc_submit i').removeClass(hide).addClass(show); }Заранее спасибо за поддержку!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy