Всем привет, вот мой ajax
function showKostenstelle()
{
var matType = document.getElementById("erzeugnisart").value;
var xhr;
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
xhr = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE 8 and older
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
var kstgrp = "kstgrp=" + matType;
xhr.open("POST", "pos/kosten.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(kstgrp);
xhr.onreadystatechange = display_data;
function display_data() {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
//alert(xhr.responseText);
document.getElementById("kostenstelle1").value = xhr.responseText;
} else {
alert('There was a problem with the request.');
}
}
}
}
A вот и сам PHP
<?php
include ("../db/connect.php");
$sql = "SELECT * FROM kosttable WHERE kstgrp LIKE '$kstgrp%'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "<option class=".$row"kstgrp"]." id=".$row["id"]." name= ".$row["fkto"]." value=".$row["kostvalue"].">".$row["test"]."</option> ";
} }
?>
Файл с id = 'erzeugnisart' тоже select, у которого value от 0 до 4
Т.е я выбираю что-то с значением "1", и в селекте kostenstelle1 у меня будут только элементы, у которых в бд kstgrp = 1;
Но при выполнении этого скрипта ничего не происходит
(ну если посмотреть в f12, то видно, что пост прошёл, в посте kstgrp 1, но в ответ приходят все элементы (у которых kstgrp от 0 до 4 )
Буду признателен за помощь
