Why can't send ajax request?

Hello! Please help me, because already long time I suffer with this form... it is impossible to submit the form without reloading the page.
<form id="form" method="post" class="popupform">
 <input type="text" placeholder="Your name" name="name" value="<?=$_POST['name']?>">
 <p class="err n" style="color:red"><?=$err['name']?></p>
 <input type="email" placeholder="Your email" name="email" value="<?=$_POST['email']?>">
 <p class="err e" style="color:red"><?=$err['email']?></p>
 <input type="text" placeholder="Your Skype" name="skype" value="<?=$_POST['skype']?>">
 <textarea name="sms" id cols="5" rows="10" placeholder="message" value="<?=$_POST['sms']?>"></textarea>

the <div>
 <button>Leave request</button>

$(document).ready(function() {
 $('#form').submit(function() { 
 if (document.form.name.value == " || document.form.email.value == " ) {
 valid = false;
 return valid;
 type: "POST",
 url: "form.php",
 data: $(this).serialize()
 }).done(function() {
 return false;

$to = 'a.kovalkovsky@gmail.com';
 $tema = 'New message';
 $name = strip_tags(trim($_POST['name']));
 $email = strip_tags(trim($_POST['email']));
 $skype = strip_tags(trim($_POST['skype']));
 $sms = strip_tags(trim($_POST['sms']));
 $message = "username: ".$name."\r\n";
 $message .= "Email: ".$email."\r\n";
 $message .= "Skype: ".$skype."\r\n";
 $message .= "Message: ".$sms."\r\n";

 $tema = "=?utf-8?B?".base64_encode($subject)."?=";
 $headers = "From: $from\r\nReply-to: $from\r\nContent-type:text/plain; charset=utf-8\r\n";
 mail($to, $tema, $message, $headers);

And why connecting the script:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
I came up with:
June 14th 19 at 19:21
1 answer
June 14th 19 at 19:23
And why ... I came up with: [gibberish]

Because the page encoding is different from the encoding that you have connected.
The easiest way to avoid this is to use everywhere UTF-8

Find more questions by tags AJAXJavaScriptPHP