我将多个XML文档称为自动完成源。我希望我的“加载”消息在加载完所有文件后消失。目前它在第一次加载后就消失了。
由于
function callAjax(data1, url){
$.ajax({
url: url,
dataType: "xml",
success:
function(xmlResponse) {
totalrec = $("TOTALREC", xmlResponse).text();
endrec = $("ENDREC", xmlResponse).text();
var data = $("ROW", xmlResponse).map(returnResults).get(data);
$.merge(data1, data);
if(endrec<totalrec){
callAjax(data1, url + "&page_no="+ parameter++);
}
$("#_results").removeClass( "ui-autocomplete-loading" ).addClass("idleField");
$("#_results").val( "Search by Application, Keyword, Process or Name" );
$("#_results").attr( "disabled", "" );
$("#_results").autocomplete({
source: data1,
minLength: 0,
selectFirst: true,
select: function(event, ui) {
if(event.keyCode == 13){
window.open(ui.item.url);
$("#_results").blur();
}
}
})
答案 0 :(得分:1)
将自动填充代码放在else
支票中的if(endrec<totalrec)
。
答案 1 :(得分:0)
像这样:
function callAjax(data1, url){$.ajax({
url: url,
dataType: "xml",
success:
function(xmlResponse) {
totalrec = $("TOTALREC", xmlResponse).text();
endrec = $("ENDREC", xmlResponse).text();
var data = $("ROW", xmlResponse).map(returnResults).get(data);
$.merge(data1, data);
if(endrec<totalrec){
callAjax(data1, url + "&page_no="+ parameter++);
} else {
$("#_results").removeClass( "ui-autocomplete-loading" ).addClass("idleField");
$("#_results").val( "Search by Application, Keyword, Process or Name" );
$("#_results").attr( "disabled", "" );
$("#_results").autocomplete({
source: data1,
minLength: 0,
selectFirst: true,
select: function(event, ui) {
if(event.keyCode == 13){
window.open(ui.item.url);
$("#_results").blur();
}
}
});
}
}
});