ajax事件未发布数据

我有2个ajax电话。 首先ajax调用填充正常工作的下拉框,第二个ajax调用使用change事件函数。 只要单击下拉列表中的动态填充项,它就会使用图像列出产品详细信息。

在下面的代码中,更改function会触发,因为它会警告所选的数据项。 但问题是从ajax里面开始的。 所以我没有得到结果(产品详情)

问题:它没有列出产品

还有如何使用var_dump($ _ POST)检查name1是否正确传递

第二个ajax代码:

  $("#name").on('change',function (e) { var name1 = this.value; alert("name1 = " + name1); $.ajax ({ data:{name1: name1}, type: 'POST', url: 'dataprod.php', success: function (response) { console.log(response); $('.products-wrp').html(''); $('.products-wrp').hide(); $('.products-wrp').html(response); $('.products-wrp').show(); }, }); });  

dataprod.php

 query("SELECT product_name, product_desc, product_code, product_image, product_price FROM products_list where product_name='$name1'"); $products_list = '
    '; while($row = $results->fetch_assoc()) { $products_list .= <<<EOT
  • {$row["product_name"]}

    Price : {$currency} {$row["product_price"]}
  • EOT; } $products_list .= '
'; echo $products_list; ?>

试试这段代码:

 ... url: '/dataprod.php' ...