ここに私のコードで私は取得し、onChangeを使用してドロップダウンからオプションを選択した後にデータを表示しようとしている、PHPファイルからデータをフェッチし、同じにテキストエリアに表示するajax経由でselect .phpファイルが残念ながら私のために働いていない混乱終了した私は間違いをした、これで私を助けてください。onChange jquery ajaxの問題を使用してデータを取得する
select.php
<head>
<script type="text/javascript">
$(document).ready(function() {
$("#channel").change(function(){
$.post("ajax.php", { channel: $(this).val() })
.success(function(data) {
$(".result").html(data);
});
});
});
</script>
</head>
<div class="col-sm-6 form-group">
<select class="chosen-select form-control" id = 'channel' name="ProductCategoryID" value="<?php echo set_value('ProductCategoryID'); ?>" required>
<option>Select Item code</option>
<?php
foreach($itemlist as $row)
{
echo '<option value="1234">'.$row->ItemCode.'</option>';
}
?>
</select>
</div>
<div class="col-sm-12 form-group result"></div>
ajax.php
<?php
define('HOST','localhost');
define('USER','***');
define('PASS','***');
define('DB','***');
$response = array();
$conn = mysqli_connect(HOST,USER,PASS,DB) or die('Unable to Connect');
//get value from page
$channel = $_POST['channel'];
$query = "SELECT * FROM gst_itemmaster where ItemCode = '$channel' ";
$result = mysqli_query($conn,$query);
$msg = '';
while($row = mysqli_fetch_array($result)) {
$msg = $msg. '<textarea type="text" class="form-control" name="Description"></textarea>'.$row['ItemDescription'].'</textarea>';
}
echo $msg;
console.log(data)を追加できます。 Ajax呼び出しの成功関数で、error_reporting(E_ALL)を追加します。あなたのajax.phpでブラウザのコンソールにサーバーのエラーや通知が表示されます。 –