mrp*_*atg 1 html javascript jquery
我希望div在页面加载一些XML内容时在我的页面上显示加载动画.一旦加载,我想隐藏这个div.我该怎么做呢?
$.ajax({
url: '/test.xml',
beforeSend: function(XMLHttpRequest) {
// Show the div before sending the request
$('#load').show();
},
complete: function(XMLHttpRequest, textStatus) {
// Hide the div no matter if the call succeeded or not
$('#load').hide();
},
success: function(xml) {
// if the request succeeds do something with the received XML
}
});
Run Code Online (Sandbox Code Playgroud)