我想在页面加载一些 XML 内容时显示一个带有加载动画的 div
。加载后,我想隐藏这个 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
}
});
关于javascript - 页面加载时显示 div,完成后隐藏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1680650/