我正在尝试使用
发送jquery ajax请求jQuery.ajax({
method: "POST",
url: "some2.php",
data: { data: result }
})
.done(function( msg ) {
alert( "Data Saved: " + msg );
});
此代码正在localhost
上正确发送请求,但在服务器上传时,则表示错误500 internal error
直播链接放在链接:
http://impulsesoftech.com/jaipurbus
我的some2.php
是
<?php
function distance($lat1, $lon1, $lat2, $lon2, $unit) {
$theta = $lon1 - $lon2;
$dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$miles = $dist * 60 * 1.1515;
$unit = strtoupper($unit);
if ($unit == "K") {
return ($miles * 1.609344);
} else if ($unit == "N") {
return ($miles * 0.8684);
} else {
return $miles;
}
}
$data = $_POST['data'];
$data = explode(",",$data);
print_r($data);
echo "Distance From Khandar Bus Stand : ".distance($data[0], $data[1], 25.992739,76.379046 "K") . " Kilometers<br>";
?>
我缺少的东西请帮帮我
答案 0 :(得分:6)
请更改
echo "Distance From Khandar Bus Stand : ".distance($data[0], $data[1], 25.992739,76.379046 "K") . " Kilometers<br>";
到
echo "Distance From Khandar Bus Stand : ".distance($data[0], $data[1], 25.992739,76.379046 , "K") . " Kilometers<br>";
您在distance
函数中缺少逗号,只是在单位参数之前调用。