0
I’m making a modal that has its content according to the link clicked.
As the content is loaded from BD, inside the modal opening Jquery I made a call in Ajax to a PHP. In this PHP I will access the database and return a table with the data. This table will be the content of the modal.
But I am unable to recover 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;
?>
Jquery is in the head of index or in the file gerarTabelaProduct.php?
– Andrei Coelho
They are in separate files?
– Andrei Coelho
Jquery is at the head of the index and gerarTabelaProduct.php is another file.
– Joca Baldini