I use the code that successfully works on 3 sites (sending the application form from the e-mail and the withdrawal of the window of thanks).
When I try to launch it on a new site, an error appears in the Chrome console (and in other browsers): http://prntscr.com/8n0rs4 (screenshot).
Form Code and JS:
<div id="modal" class="modal"> <div class="text" align="center"> <form id="mailer_form" action="mailer.php" method="post" class="form1"> <h3>Оставьте заявку и<br>получите расчет стоимости</h3> <input type="text" name="name" class="inputbox" placeholder="Ваше имя:" required> <input type="text" name="phone" class="inputbox" placeholder="Ваш телефон:" required> <input type="submit" name="submit" class="button" value="Заказать цветы"> <a href="#close" title="Закрыть"></a> </form> </div> </div>
<script> //callback handler for form submit $("#mailer_form").submit(function(e) { var postData = $(this).serializeArray(); var formURL = $(this).attr("action"); $.ajax( { url : formURL, type: "POST", data : postData, success:function(data, textStatus, jqXHR) { data_result = JSON.parse(data); if(typeof data_result === 'undefined') { // alert('Problem with returned JSON'); }else{ if(parseInt(data_result.success) === 1 && parseInt(data_result.error) === 0) { var html_result="<h3>Спасибо за вашу заявку!<br><br>Мы свяжемся с Вами<br>в ближайшее время!</h3><img src='img/up.png' style='margin-top: 35px;'>" $('div#modal div.text').html(html_result); //alert("OK"); }else if(parseInt(data_result.success) === 0 && parseInt(data_result.error) === 1) { // alert(data_result.msg); } } }, error: function(jqXHR, textStatus, errorThrown) { // alert("Error!"); console.log(data); } }); e.preventDefault(); //STOP default action // e.unbind(); //unbind. to stop multiple form submit. }); </script>
I repeat that this code works fine on other sites. Copied 1 to 1, the same scripts are connected.
What could be the problem?