<!DOCTYPE html>
<html>
<head>
<title>jQuery例子</title>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Expires" content="0">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Cache" content="no-cache">
<script src="./js/jquery-3.2.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
function demo1(){
//$.ajax("test.html")
$.ajax("./js/jquery-3.2.1.js")
.done(function(){ console.log("哈哈,成功了!"); })
.fail(function(){ console.log("出错啦!"); });
}
//demo1();
function demo2(){
//$.ajax("test.html")
$.ajax({url:"./js/jquery-3.2.1.js",method:"POST"})
.done(function(){ console.log("哈哈,成功了!"); })
.fail(function(){ console.log("出错啦!"); });
}
//demo2();
function demo3(){
//$.ajax("test.html")
$.ajax({url:"./js/jquery-3.2.1.js",method:"POST"})
.done(function(){ console.log("哈哈,成功了!");} )
.fail(function(){ console.error("出错啦!"); } )
.done(function(){ console.log("第二个回调函数!");} );
}
//demo3();
function demo4(){
$.when($.ajax("test1.html"), $.ajax("test2.html"))
.done(function(){ alert("哈哈,成功了!"); })
.fail(function(){ alert("出错啦!"); });
}
//demo4();
function demo5(){
$.when($.ajax("test1.html"), $.ajax("test2.html"))
.done(function(){ alert("哈哈,成功了!"); })
.fail(function(){ alert("出错啦111!"); })
.fail(function(){ alert("出错啦222!"); } )
.done(function(){ alert("第二个回调函数!");} );
}
demo5();
});
</script>
</head>
<body>
</body>
</html>
html5 模板
最新推荐文章于 2024-03-12 09:22:55 发布