Javascript ajax请求不响应

Javascript ajax请求不响应,javascript,php,ajax,Javascript,Php,Ajax,这是我的代码我做了什么 function price() { var quantity = document.getElementById("quan").value; var select = document.getElementById("p_id"); var product_id = select.options[select.selectedIndex].value; if (window.XMLHttpRequest) { /

这是我的代码我做了什么

function price() {

    var quantity = document.getElementById("quan").value;
    var select = document.getElementById("p_id");
    var product_id = select.options[select.selectedIndex].value;



    if (window.XMLHttpRequest) {
        // code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp = new XMLHttpRequest();
    } else { // code for IE6, IE5
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
            //alert("working");
            document.getElementById("price_ajax").innerHTML = this.responseText;
        }
    }
    xmlhttp.open("GET", "get_product.php?p_id=" + product_id + "&quantity=" + quantity);
    xmlhttp.send();
<input class="form-control" type="number" name="price[]" id="price_ajax" >
下面是我执行ajax请求的php代码:

$p_id = intval($_GET['p_id']);
$quantity = intval($_GET['quantity']);

$connection=new Database();



$sth=$connection->DBH->prepare("SELECT `unit_price` FROM `product_lookup` WHERE `id`=?");

$sth->bindParam(1,$p_id);
$sth->setFetchMode(PDO::FETCH_OBJ);
$rs=$sth->execute();
$row =$sth->fetch();


$product_price= intval($row->unit_price);

$total_price=$product_price*$quantity;

?>

<input value="<?php echo $p_id?>">
<input class="form-control" type="number" name="price[]" id="price_ajax" >
$p_id=intval($_GET['p_id']);
$quantity=intval($_GET['quantity']);
$connection=新数据库();
$sth=$connection->DBH->prepare(“从'product\u lookup'中选择'unit\u price',其中'id`=?”;
$sth->bindParam(1,$p_id);
$sth->setFetchMode(PDO::FETCH_OBJ);
$rs=$sth->execute();
$row=$sth->fetch();
$product\U price=intval($row->单价);
$总价=$产品价格*$数量;
?>

我想你忘了包括你的HTMLNow你忘了包括你实际调用价格的地方()@blue Boy我包括HTMLNow按F12并查看控制台@mplungjan我添加了oninput