我正在尝试将 jQuery 值传递给 PHP,如下所示:
var your_var_value=1200;
$.ajax({
type: "POST",
url: "scripts/php/controllers/tariff.fare.controller.php",
data: { var_value: your_var_value},
error:function(request){alert(request.statusText)},
success:function(result){
alert(your_var_value);
}
});
到以下:
<?php
require_once('models/sql.php');
require_once('models/server.php');
require_once('models/journey.php');
class TariffFareController {
// If there is no fixed fare, use route calc
if ($fixed_fare_result == null) {
$distance=$_POST['var_value'];
if ($distance > 1100) {
$fare = 222.00;
}
else {
$fare = 111.00;
}
//MORE CODE
}
但是当我这样做时,我得到一个500 Internal Server Error
我知道我传递给它的 URL 是正确的,有什么想法吗?