index.html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Contador de clicks sem refresh</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script>
$(document).ready(function() {
$('a').click(function(){
var valor_id = $(this).attr("id");
// Variável que receberá o objeto XMLHttpRequest
var req;
// Verificar o Browser
// Firefox, Google Chrome, Safari e outros
if(window.XMLHttpRequest) {
req = new XMLHttpRequest();
}
// Internet Explorer
else if(window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
var url = "click.php?valor_id="+valor_id;
req.open("Get", url, true);
});
});
</script>
</head>
<body>
<a href="http://x.blogspot.com" id="2">Clique</a>
</body>
</html>
click.php
<?php
// Incluimos o arquivo de conexão
include ("class/class.MySQL.php");
// Cria Obejto
$mySQL = new MySQL;
// Recuperamos os valores dos campos através do método GET
$valor_id = $_GET['valor_id'];
if (!empty($valor_id)) {
$altera = $mySQL->sql("UPDATE link SET click = click + 1 WHERE id = '".$valor_id."' LIMIT 1");
// Fim atualiza visitas...
}
?>










