Why not send the file and do not load the file?

Hi all. Wanted to make sending messages on email.email without page refresh.
Found the article: https://habrahabr.ru/sandbox/93363/
But for some reason clicking the button does not send anything at all and as I understand it does not load the file send.php
Will show that is necessary. In advance I will be grateful
Code in the header:
<script type="text/javascript">
$(document).ready(function(){
 $("#form").submit(function() { //set the send event for the form with id=form
 var form_data = $(this).serialize(); //sobiraem all the data from the form
$.ajax({
 type: "POST", //submit Method
 url: "ol.php", //path to php file sender
 data: form_data,
 success: function() {
 //code in this block is executed upon successful sending of a message
 alert("Your message otpravleno!");
});
});
}); 
</script>

Form code:
<form id="form" class="action-form">
the <div>
 <label for><i class="fa fa-user"></i></label>
 <input type="text" value name="name" class="itext osans ia-person" placeholder="Your name">
</div>
the <div>
 <label for><i class="fa fa-phone"></i></label>
 <input type="tel" value name="phone" class="itext osans ia-phone" placeholder="Enter phone number">
</div>
the <div>
 <label for><i class="fa fa-envelope-o"></i></label>
 <input type="text" value name="email" class="itext osans ia-email" placeholder="Enter email">
</div>
the <div>
 <center><input style="border: none;background: #E74C3C;border-bottom: 2px solid #cc4135;padding: 10px 40px 10px 40px;text-decoration: none;color: #fff;" type="submit" value="Get advice" class="ibutton"></center>
</div>
 </form>

code ol.php
<?
if((isset($_POST['email'])&&$_POST['email']!="")&&(isset($_POST['name'])&&$_POST['name']!="")&&(isset($_POST['phone'])&&$_POST['phone']!="")){ //Check went our name field is not empty and if they
 $to = 'splek@inbox.ru'; //Email of recipient separated by comma, you can specify any number of addresses
 $subject = 'callback'; //the Comany messages
 $message = '
<html-->

<title>'.$subject.'</title>


 <p>Name: '.$_POST['name'].'</p>
 <p>Phone: '.$_POST['phone'].'</p> 

 '; //The text of our messages you can use HTML tags
 $headers = "Content-type: text/html; charset=utf-8 \r\n"; //Encoding of the letter
 $headers .= "From: the Sender <from@example.com>\r\n"; //Name and email of the sender
 mail($to, $subject, $message, $headers); //Send emails using mail function
}
?></from@example.com>


in the address bar is added when the button is pressed:

?name=ФИО&phone=11111111111&email=test%40gmail.com
August 23rd 19 at 10:35
1 answer
August 23rd 19 at 10:37
Solution
You are missing the closing quotation mark, success: function, js does not work out, so it should work
$(document).ready(function(){
 $("#form").submit(function() { //set the send event for the form with id=form
 var form_data = $(this).serialize(); //sobiraem all the data from the form
$.ajax({
 type: "POST", //submit Method
 url: "send.php", //path to php file sender
 data: form_data,
 success: function() {
 //code in this block is executed upon successful sending of a message
 alert("Your message otpravleno!");
}
});
});
});
nope. in the address bar the data is transmitted and all - Teagan_Tow commented on August 23rd 19 at 10:40
: codepen.io/DenisBardak/pen/ygXWeO so, it's working! - sherwood_Koepp commented on August 23rd 19 at 10:43
it does not even file. I have to check the forwarding set. but nothing - Teagan_Tow commented on August 23rd 19 at 10:46
: I'm for example not see anything( - Teagan_Tow commented on August 23rd 19 at 10:49
in the inspector, go to the data send.php - sherwood_Koepp commented on August 23rd 19 at 10:52
: hmmm.strange as the code you need after libraries to write Yes? just the download of the libraries in my footer. and the code from above - Teagan_Tow commented on August 23rd 19 at 10:55
Yes, it took data. - Teagan_Tow commented on August 23rd 19 at 10:58
: thank you - Teagan_Tow commented on August 23rd 19 at 11:01
: Yes, after the library, open the inspector, look error. for chrome ctrl+shift+i , Console contribution - sherwood_Koepp commented on August 23rd 19 at 11:04

Find more questions by tags E-mailJavaScriptPHP