<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>title</title>
<style>
.cover {
height: 100%;
width: 100%;
position: absolute;
left: 0;
top: 0;
background-color: skyblue;
opacity: .5;
display: none;
}
</style>
</head>
<body>
<h2>jQuery_ajax使用补充</h2>
<input class='json' type="button" value='获取JSON'>
<input class='XML' type="button" value='获取XML'>
<div class="cover"></div>
</body>
</html>
<script src="./jquery-1.12.4.min.js"></script>
<script>
$(function () {
$('.json').click(function () {
$.ajax({
url: '../00.backData/backJSON.php',
success: function (data) {
console.log(data);
},
dataType: 'json'
})
})
$('.XML').click(function () {
$.ajax({
url: '../00.backData/backXML.php',
success: function (data) {
console.log(data);
},
dataType: 'xml'
})
})
})
$(document).ajaxStart(function(){
$('.cover').show();
});
$(document).ajaxComplete(function(){
$('.cover').hide();
});
</script>