The accepted solution did not work for me. This is how I read a .txt
for my jQuery autocomplete input field:
$.ajax({
url: "foo/bar.txt",
dataType: "text",
success: function(data) {
var autoCompleteData = data.split('
');
$("#input").autocomplete({
source: function(request, response) {
var results = $.ui.autocomplete.filter(autoCompleteData, request.term);
response(results.slice(0, 10)); // Display the first 10 results
}
});
}
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…