52,797
社区成员
发帖
与我相关
我的任务
分享
<!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事件应用示例</title>
<style type="text/css">
button, div, li, a {
font-size: 12px;
font-family: Tahoma;
}
#loading {
display: none;
}
</style>
<script type="text/javascript" src="jquery.js">
</script>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
var url = "http://services.digg.com/stories/top?appkey=http%3A%2F%2Fmashup.com&type=javascript&callback=?";
$.getJSON(url, function(data){
$.each(data.stories, function(i, story){
var content = "<li><a href='" + story.href + "' target='_blank'>" + story.title + "</a>";
$("#res ul").append(content);
if (i == 3)
return false;
});
});
});
$().ajaxStart(function(){
$("#loading").show();
}).ajaxStop(function(){
$(this).hide();
});
});
</script>
</head>
<body>
<button>
加载数据
</button>
<div id="loading">
数据加载中...<img src="images/ajax-loader.gif" />
</div>
<div id="res">
<ul type="square">
</ul>
</div>
</body>
</html>
<!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=gb2312" />
<title>全局Ajax事件应用示例</title>
<style type="text/css">
button, div, li, a {
font-size: 12px;
font-family: Tahoma;
}
#loading {
display: none;
}
</style>
<script type="text/javascript" src="jq.js">
</script>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
var url = "http://services.digg.com/stories/top?appkey=http%3A%2F%2Fmashup.com&type=javascript&callback=?";
$.getJSON(url, function(data){
$.each(data.stories, function(i, story){
var content = "<li><a href='" + story.href + "' target='_blank'>" + story.title + "</a>";
$("#res ul").append(content);
if (i == 3)
return false;
});
});
});
//==========
$('#loading').ajaxStart(function(){
$(this).show();
}).ajaxStop(function(){
$(this).hide();
});
});
</script>
</head>
<body>
<button>
加载数据
</button>
<div id="loading">
数据加载中...<img src="images/ajax-loader.gif" />
</div>
<div id="res">
<ul type="square">
</ul>
</div>
</body>
</html>
$("#show").ajaxSend(function(){
$(this).html("<img id=\"loading\" src=\"images/loading.gif\" />");
});
$("#show").ajaxComplete(function(){
$(this).show();
});
$.get("AjaxValidate/GetCarListInfo.aspx?conditions=" + encodeURIComponent(condis),function(data){
var arr = data.split('--');
show.innerHTML = arr[1]; //显示车辆列表
document.getElementById("divSplitPage").innerHTML = arr[0];
window.parent.lastpageno = (arr[2].split('='))[1];//设置最后一页的页码