I'm beginner of php and javascript so i dont really now whats the wrong in my code. i just want to send a javascript variable to php and its not working, i dont now why. These files all different pages. So its a click function in javascript:
file: SelectTableRow.js.
var productTable = document.getElementById('ProductTable'), rIndexB;
for(var i = 0; i < productTable.rows.length; i++)
{
productTable.rows[i].onclick = function()
{
rIndex = this.rowsIndexB;
var bAzon = this.cells[0].innerHTML;
$.post("AddProductTable.php", {BAzon: bAzon}, function(){
$('#load').load('AddProductTable.php');
});
console.log(bAzon);
}
}
The database is running clear too. The data what should display:
file: AddProductTable.php
<table class="DataTable">
<th>Azonosito</th>
<th>Név</th>
<th>Mennyiség</th>
<th>Mértékegység</th>
<th>Ár</th>
<th>Törlés</th>
<?php
require_once 'Connect.php'; // its 100% working.
$BAzon = $_POST['BAzon']; // 0 result :(
if($result = $link_database->query("SELECT bevetAzon, termekAzon, bevettMennyiseg, bevettAr FROM bevetttermek WHERE bevetAzon = '$BAzon'"))
{
$table = $result->fetch_all();
foreach($table as $row)
{
echo "<tr>";
foreach($row as $record)
{
echo "<td>".$record."</td>";
}
echo "</tr>";
}
}
echo "BAZON: ".$BAzon; //0 result
echo "POST: ".$_POST['BAzon']; // 0 result
?>
</table>
and the file where i call this(just the important part):
Index.php
<div id="load">
</div>
When im trying a test number, its working, display the datas. Please help me, i cant go through this one.