Qué opináis de esta forma?
Es funcional
Código HTML:
Ver original<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> body, h1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 0.8em;
}
a {
text-decoration: none;
color: #333;
}
a:hover {
color: #ff0000;
}
#ajax-content {
height: auto;
width: 400px;
border: 5px solid #ccc;
margin: 0 auto;
padding: 10px;
}
#loading {
width: 66px;
margin: 0 auto;
}
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
$(document).ready(function(){
$("#loading").css("display", "none");
$("#ajax-content").css("display", "none");
$("#enlaceajax").click(function(evento){
evento.preventDefault();
$("#loading").css("display", "inline");
$("#ajax-content").css("display", "none");
$("#ajax-content").load("test.php", function(){
$("#loading").css("display", "none");
$("#ajax-content").css("display", "block");
});
});
})
<a href="#" id="enlaceajax">Haz clic!
</a> <img src="generator.php.gif" alt="content is loading" width="100" height="100" />