E-mail is sent, but the alert is not displayed. Why?

On this page, send the application form at the top of the letter, but the alert does not appear...

Form:

<form id="form" onsubmit="yaCounter44033839.reachGoal('NEW_MESSAGE'); return true;">
 <ul class="form-fields">
 the <li><label>Your name</label>
 <input type="text" name="name" required="required"></li>
the <li><label>Phone</label>
 <input type="text" name="phone" required="required"></li></ul>
 <button class="btn form-btn green-btn">make an Appointment</button>
 </form>


JS:

<script type="text/javascript">$(document).ready(function(){
 $("#form").submit(function() {
 var form_data = $(this).serialize();
$.ajax({
 type: "POST",
 url: "send.php",
 data: form_data,
 success: function() {
 alert("Your message sent!");
 } 
});
});
});
 </script>


PHP:
<?php
if( ! empty($_POST) ) {

 $data = (object) $_POST;

 if( ! $data--->name) return 'the Name Field is not filled in.';
 if( ! $data->phone) return 'the phone Field is not filled in.';

 $to = 'razvod.2018@mail.ru';
 $subject = 'the applications';
 $message = 'the Name' . $data->name . '. Phone ' . $data->phone;

 $headers = "Content-type: text/html; charset=utf-8 \r\n";
 $headers .= "From: Morisod <from@example.com>\r\n";


 mail($to, $subject, $message, $headers);

 return 'the Script has finished its work';

} else {
 return 'the Form is blank.';
}</from@example.com>
June 27th 19 at 15:25
1 answer
June 27th 19 at 15:27
Solution
try to hang alert for "complete"
thanks for help - Malcolm_Rempel commented on June 27th 19 at 15:30

Find more questions by tags HTMLPHPWeb Development