id_function.php が完全に正常に動作する出力が得られません。誰か助けてください。
JavaScript
function get_details()
{
var oriz = document.getElementById("from").value;
var dizz = document.getElementById("to").value;
var id_orig_diz = $.ajax({
type: "POST",
url: 'id_function.php?orig='+oriz+'&des_id='+dizz,
dataType: "text",
async: false
}).responseText;
alert(id_orig_diz);
}
これは私のPHPですが、IDを取得していません
<?php
$name_1 = $_GET['orig'];
$name_2 = $_GET['des_id'];
try {
$dbuser = "kim";
$dbpass = "kim";
$conn = new PDO('mysql:host=localhost;dbname=destination', $dbuser, $dbpass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("SELECT pl_id FROM view_places WHERE name = :name LIMIT 1");
$stmt->bindParam(':name',$name_1);
$stmt->execute();
$result_1 = $stmt -> fetch();
$res1 = $result_1["pl_id"];
$stmt->bindParam(':name', $name_2);
$stmt->execute();
$result_2 = $stmt -> fetch();
$res2 = $result_2["pl_id"];
echo 'origin_number:'.$res1. ', '.'destination_id:'.$res2;
} catch(PDOException $e) {
echo 'ERROR: ' . $e->getMessage();
}
?>