最簡單的高級代碼應該如下所示,其中requestFromSource1是您請求geonames的位置,requestFromSource2是您查詢自己的自動填充引擎的位置。
$("#city").autocomplete({
source: function(request, response) {
var resultFromSource1 = null;
var resultFromSource2 = null;
var agregateResults = function(){
if(resultFromSource1 && resultFromSource2){
var result = resultFromSource1.concat(resultFromSource2);
response(result);
}
}
requestFromSource1(function(result){
resultFromSource1 = result;
agregateResults();
});
requestFromSource2(function(result){
resultFromSource2 = result;
agregateResults();
});
}
});
});
更復雜的情況是通過相關性分數合併。恐怕你的情況可能會發生這樣的情況。
將一個數組內的所有數據源合併,然後使用 – sdespont