Why sending messages via ajax does not work in all browsers?

Is there a website on Wordpress. Sending via ajax. Why do not all browsers "Message sent". Something where the "Message not sent". Rather, apparently, plays the role of the browser version, because I have in all browsers (Chrome, Yandex, Mozilla, Opera, Safari) everything is fine. The client not all is sent. Know at least about Yandex.Browser.
Here is the code:
<?php
$mail = 'dummy@yandex.ru';
if ( isset($_POST["name"]) && isset($_POST["tel"]) && isset($_POST["proc"]) && isset($_POST["date"]) ) { 
 if ( $_POST["name"]!=" && $_POST["tel"]!=" && $_POST["date"]!=" && $_POST["proc"]!=" ){
 // Generated array for JSON response
 $result = array(
 'name' => $_POST["name"],
 'tel' => $_POST["tel"],
 'proc' => $_POST["proc"],
 'date' => $_POST["date"]
 ); 
 // Converting array to JSON
 echo json_encode($result); 
}else{
 alert('Complete the fields');
}
}
 $headers = 'From: no-reply@dummy.ru' . "\r\n" .
 'Reply-To: no-reply@dummy.ru' . "\r\n" .
 'X-Mailer: PHP/' . phpversion();
 $title = 'appointments';
$message="
 Name: ".iconv( 'UTF-8','utf-8',$_POST['name'])."
 Phone: ".iconv( 'UTF-8','utf-8',$_POST['tel'])."
 Procedure: ".iconv( 'UTF-8','utf-8',$_POST['proc'])."
 Date: ".iconv( 'UTF-8','utf-8',$_POST['date']);
 mail($mail, $title, $message, $headers);
?>

JS:
$( document ).ready(function() {
$("#btn").click(
function(){
 sendAjaxForm('result_form', 'ajax_form', 'action_ajax_form.php');
 return false; 
}
);
});
function sendAjaxForm(result_form, ajax_form, url) {
$.ajax({
 url: 'action_ajax_form.php', //page url (action_ajax_form.php)
 type: "POST", //submit method
 dataType: "html", //data format
 data: $("#"+ajax_form).serialize(), // Serilizer object
 success: function(response) { //Data sent successfully
 result = $.parseJSON(response);
 $('#result_form').html('Name: '+result.name+'<br>Phone: '+result.tel+'<br>Procedure: '+result.proc+'<br>date: '+result.date);
swal({
 type: 'success',
 text: 'Message sent',
});
},
 error: function(response) { // Data not sent
 $('#result_form').html('Error. Data is not sent.');
swal({
 type: 'error',
 text: 'Message not sent',
});
}
});
}

-------------------------------------
UPD:
It turned out that not only sent when a transition from Yandex, because https is added. With https in the address does not send the message. What to do?
March 19th 20 at 08:49
2 answers
March 19th 20 at 08:51
Solution
UPD:
It turned out that not only sent when a transition from Yandex, because https is added. With https in the address does not send the message.
Fixed http to https:
url: 'https://dummy.ru/action_ajax_form.php', //page url (action_ajax_form.php)
March 19th 20 at 08:53
And, it will list browsers for which you want compatibility.
Next, I think, is not a problem to debug the script for each individual.
Neither you nor we should not wonder that there is a "not all" the browsers at the client, and maybe he even meant Netscape Navigator.
And how is it possible to do? For example it will list the versions of browsers, and then what? - clair.Walter commented on March 19th 20 at 08:56
First - check that the script works in every browser.
If something goes wrong - torment already the script itself and the appropriate browser for compatibility.
In extreme cases, one could say that supporting a browser is not possible, but that the client should be called really ancient browsers that don't know about xhr. - Forrest_Rempel25 commented on March 19th 20 at 08:59
Seems 2 ways

1. Add debugging to the collection of information about the used client (browser)

2. To find a replacement for the functionality to test first - what functions will work in all browsers. - Claude.Zeml commented on March 19th 20 at 09:02
And what's the problem to ask the customer?

Well, okay, if you don't have to ask, then the easiest way is to take the bare XMLHttpRequest and accessing ActiveX for ancient IE. If that doesn't help, then nothing will, and we can talk about the impossibility of a normal ajax support.
Example, needing
function postData() {
 var http;

 if (window.XMLHttpRequest) {
 // code for IE7+, Firefox, Chrome, Opera, Safari
 http = new XMLHttpRequest();
}
 else {
 // code for IE6, IE5
 http = new ActiveXObject("Microsoft.XMLHTTP");
}
 var url = "/script.php";
 var params = "";
 http.open("GET", url, true);

 //Send the proper header information along with the request
 http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
 http.setRequestHeader("Content-length", params.length);
 http.setRequestHeader("Connection", "close");
 http.onreadystatechange = function() { //Call a function when the state changes.
 if(http.readyState == 4 && http.status == 200) {

}
}
http.send(params);
}
- Forrest_Rempel25 commented on March 19th 20 at 09:05
@Forrest_Rempel25, there is no problem. Ask. - clair.Walter commented on March 19th 20 at 09:08

Find more questions by tags PHPAJAX