I'm having trouble sending an Ajax variable to PHP, the situation is as follows:
Using while
, all available albums in the database are listed:
include './bd/conecta.php';
$sql = "SELECT * FROM album";
$query = mysql_query($sql);
while ($row = mysql_fetch_array($query)) {
echo '<a href="">' . '<img width="100px" heigth="100px" src="' . $row['capa_album'] . '" onclick="alb(' . $row['id_album'] . ')" ></a>';
}
Ajax code I can see this id_album
through alert
, but I can not send this id_album
variable to the fotos.php
page.
function alb(codigo) {
$.ajax({
url: 'fotos.php',
cache: false,
type: 'POST',
data: 'id_album=' + codigo,
success: function(data) {
alert(codigo);
}
});
};
Actually neither redirecting is to the fotos.php page, can anyone help me?