Jquery实现ajax loading加载效果

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>AJAX TEST</title>
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(function(){
$('#button').click(function(){
$.ajax({
   url:'demo.php',
   type: "POST",
   data: ({name:'wang',location:'AJAX'}),
   beforeSend:Request,
   success:Response,
});
   });
  
});
function Request(){
   $('#loading_img').html('<img src="ajax-loader.gif" width="35" height="35" />');
}
function Response(data){
   $('#loading_img').html(data);
}
</script>
</head>

<body>

<div id="loading_img"></div>
<input type="button" name="demo" id="button" value="TEST"/>
</body>
</html>

posted @ 2012-06-01 21:33  暮色灯塔  阅读(2620)  评论(0编辑  收藏  举报