<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Prova Ajax</title>
<style>
.myButton { width: 130px; height: 60px; }
</style>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.myButton').click(function() {
var bt = ($(this).attr("value"));
alert(bt);
if(bt != 0) {
$.ajax({
type: 'post',
cache: false,
url: 'esempio_13.php',
data: 'query='+bt,
success:function(html) {
$('#tabella').html(html);
},
error: function(request, status, error) {
$('#tabella').html('<br />ERRORE : il server non risponde o lo ha fatto in modo anomalo '+request.responseText);
}
});
}
else {
$('#tabella').html('Seleziona la tabella da visualizzare');
}
});
});
</script>
</head>
<body>
<button class="myButton" name="button1" value="1">tabella 1</button>
<button class="myButton" name="button2" value="2">tabella 2</button>
<button class="myButton" name="button3" value="3">tabella 3</button>
<br />
<div id="tabella"> </div>
</body>
</html>