let data = {
distance: 2,
}
let jsonData = JSON.stringify(data);
$.ajax({
url: 'URL/To/Yout/PHP/File',
method: 'post',
data: jsonData,
dataType: 'json',
contentType: 'application/json; charset=utf-8',
success: (xhr) => {
alert("Success");
},
error: (xhr) => {
alert("Error");
}
});