2
如果數據在服務器或服務器中不可用或者服務器數據爲空,則JavaScript會拋出異常obj is null
。如何捕捉這個異常?什麼是處理typeahead/Bloodhound代碼拋出異常的正確方法?
在stackoverflow中搜索沒有給出任何結果。
下面的代碼:
var test1 = new Bloodhound({
datumTokenizer: function (d) {
return Bloodhound.tokenizers.whitespace(d.value);
},
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: "http://URL?query=",
replace: function(url, query) {
return url + "" + query;
}
}
});
test1.initialize();
$('#idOfAutoCompleteTextBox').typeahead({
hint: true,
highlight: true,
minLength: 1
},
{
name: 'test1',
displayKey: 'value',
source: test1.ttAdapter()
});
你能如何,這可能有助於解決樓主的問題,這個問題詳細點嗎?我不太關注你。 – Kmeixner
遠程PHP的來源不存在的問題,所以我不能給出一個確切的解決方案 –