I'm making a modal that has its content according to the clicked link.
As the content is loaded from the DB, within the modal opening JQuery I made an Ajax call to a PHP. In this PHP I will access the database and return a table with the data. This table will be the modal content.
But I am not able to retrieve the parameter passed by Ajax in PHP.
Error:
Notice: Undefined index: idCategoria in C:\xampp\htdocs\canaa\gerarTabelaProduto.php on line 5
Notice: Undefined property: mysqli::$num_rows in C:\xampp\htdocs\canaa\gerarTabelaProduto.php on line 9
JQuery / Ajax:
$.ajax({
url: "gerarTabelaProduto.php",
type: "POST",
data: {
idCategoria: id
},
contentType: false,
cache: false,
processData:false,
success: function(data)
{
$("#conteudoModalProduto").html(data);
}
});
PHP:
<?php
require_once "admin/conexao.php";
$idCategoria = $_POST["idCategoria"];
$nomeCategoria = "";
$categoria = $conexao->query("SELECT * FROM categoria WHERE idCategoria =".$idCategoria);
if($conexao->num_rows <> 0){
$nomeCategoria = $categoria['nome'];
}
echo $nomeCategoria;
?>