52,799
社区成员
发帖
与我相关
我的任务
分享
<!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(){
$.ajaxSetup({
cache:false,
});
$("#loading").ajaxStart(function(){
$(this).show();
}).ajaxStop(function(){
$(this).hide();
}).ajaxError(function(){
alert("error");
});
$("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;
});
});
// $.ajax({
// url: url,
// data: {
// "appkey": "appkey=http%3A%2F%2Fmashup.com",
// "type": "javascript"
// },
// dataType: "jsonp",
// cache: false,
// Type: "GET",
// success: 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;
// });
// }
// })
});
});
</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=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(){
$("#loading").ajaxStart(function(){
$(this).show();
}).ajaxStop(function(){
$(this).hide();
}).ajaxError(function(){
alert("error");
});
$("button").click(function(){
var url = "http://services.digg.com/stories/top?appkey=http%3A%2F%2Fmashup.com&type=javascript&callback=?d="+Math.random();
// var url = "http://services.digg.com/stories/top?appkey=http%3A%2F%2Fmashup.com&type=javascript&callback=?&d="+Math.random();
$.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;
});
});
});
});
</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=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-1.4.2.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>
<!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-1.6.1.js">
</script>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
$("#loading").show();
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").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=utf-8" />
<title>全局Ajax事件应用示例</title>
<style type="text/css">
button, div, li, a {
font-size: 12px;
font-family: Tahoma;
}
#loading {
display: none;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript"></script>
<!--<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript"></script>-->
</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(){
alert("ajaxStart");
$(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>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<script type="text/javascript" src="jquery.js">
</script>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
$.ajaxSetup({
url: "ajax.txt",
success: function(result){
$("div").html(result);
}
});
$.ajax();
});
});
</script>
</head>
<body>
<div id="txt">
<h2>通过 AJAX 改变文本</h2>
</div>
<button>
改变内容
</button>
</body>
</html>