Allora ho provato qualche altra cosa vi faccio vedere, precisamente quello che dice pietro09 nella discussione ajax che andreadovicchi mi aveva mostrato:
http://forum.html.it/forum/showthrea...readid=1071699
index.php:
codice:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento senza titolo</title>
<script language="javascript" type="text/javascript">
// <!CDATA[
function caricaBox(string, IdBox) {
var url_action = string;
new Ajax.Request(url_action, { onComplete: showResponse });
function showResponse(originalRequest) {
var t = originalRequest.responseText;
t = execJS(t);
$(IdBox).innerHTML = t;
}
return false;
}
function execJS(t) {
var p1 = 0, p2 = 0, p3 = 0, p4 = 0;
p1 = t.indexOf("<" + "script", 0);
if (p1 == -1) return t;
p2 = t.indexOf(">", p1 + 7) + 1;
p3 = t.indexOf("<" + "/script>", p2);
p4 = p3 + 9;
var c = t.substring(p2, p3);
var s = document.createElement("script");
s.type = "text/javascript";
s.text = c;
document.getElementsByTagName("head")[0].appendChild(s);
t = t.substring(0, p1) + t.substr(p4);
return execJS(t);
}
// ]]>
</script>
</head>
<body>
<div><?php
@include 'catalogo/config.php';
// recupero i dati dal DB
........
$id = $f['id'];
$nome = stripslashes($f['nome']);
$descrizione = stripslashes($f['descrizione']);
//stampiamo
echo "<a href=\"catalogo/prodotto.php?id=". $id ."\" onclick=\"javascript:caricaBox(this.href, 'div1');return false;\">";
echo $nome . "</br>" ;
echo "</a>" ;
}
@mysql_close($cn);
?></div>
<div id="div1">ciao</div>
</body>
</html>
Così facendo la pagina prodotto.php viene aperta in una nuova pagina e non dentro il div1