Display loading image while post with ajax
- by DonJoe
I know there are thousands of examples on the internet, but I want for the script I already have to display a loading gif image while the data is retrievedd. My java knowledge are poor, therefore I'm asking how to change the following:
<script type="text/javascript">
$(document).ready(function(){
function getData(p){
var page=p;
$.ajax({
url: "loadData.php?id=<? echo $id; ?>",
type: "POST",
cache: false,
data: "&page="+ page,
success : function(html){
$(".content").html(html);
}
});
}
getData(1);
$(".page").live("click", function(){
var id = $(this).attr("class");
getData(id.substr(8));
});
});
</script>
And my div is here:
<div class="content" id="data"></div>
Thanks.
John