我有一个小的 ajax jquery 脚本,它为我返回一些 XML。虽然它正在工作并与服务器通信,但我正在显示加载器动画。
问题是我看不到动画。要么我做错了什么,要么网络连接非常快。
有谁知道如何在我的 ajax 代码中引入延迟以减慢进程并测试动画功能?
谢谢你。
ps:ajax代码在下面,以防万一
function fetchData($nodeid, $area){
if( $nodeid != $currentRoomId ){
popupBox($area);//$area, $roomInfo);
}
var $nid, $title, $classroom, $boardroom, $cabaret;
$.ajax({
url: "/room/" + $nodeid + "/rss.xml",
dataType: "xml",
success: function($xml){
$returnXML = $xml;
$($xml).find('node > *').each(
function(){
switch( $(this).attr('name') ){
case 'Nid':
$nid = $(this).text();
break;
case 'Title':
$title = $(this).text();
break;
case 'Classroom':
$classroom = $(this).text();
break;
case 'Boardroom':
$boardroom = $(this).text();
break;
case 'Cabaret':
$cabaret = $(this).text();
break;
case 'Theatre':
$theatre = $(this).text();
break;
case 'Notes':
$notes = $(this).text();
break;
default:
break;
}//close switch statement
}
);
$roomInfo = new Array();
$roomInfo.push('Title', $title);
$roomInfo.push('Classroom', $classroom);
$roomInfo.push('Boardroom', $boardroom);
$roomInfo.push('Cabaret', $cabaret);
$roomInfo.push('Theatre', $theatre);
$roomInfo.push('Notes', $notes);
highlightRow($nid);
popupBox($area, $roomInfo);
},
statusCode: {
200: function(){
//alert('responding just fine!');
}
},
error: function(){
//alert('Ajax not responding!');
},
complete: function(){
//alert('completed!');
}
});
}