Display loading image while post with ajax
Posted
by DonJoe
on Stack Overflow
See other posts from Stack Overflow
or by DonJoe
Published on 2010-03-24T17:00:43Z
Indexed on
2010/03/24
17:03 UTC
Read the original article
Hit count: 266
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
© Stack Overflow or respective owner