0
私はブートストラップオートコンプリート(Typeahead)リストに外部Webサービス(この場合は "Wunderground Weather")が提供するデータを埋めようとしていますが、機能しません。TypeaheadオートコンプリートAJAX
「hasOwnProperty」というエラーが戻ってきます。私は問題が機能autoCompleteWunderGround()の戻り値であると思い
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="bootstrap-typeahead.js"></script>
HTML
<div class="col-md-12">
<h1>Search Dynamic Autocomplete using Bootstrap Typeahead JS</h1>
<input class="typeahead form-control" type="text">
</div>
jQueryの
$(".typeahead").typeahead({
source: function (query,process) {
return process(autoCompleteWunderGround(query))
}
});
function autoCompleteWunderGround(query){
var results = []
$.ajax({
url : "http://autocomplete.wunderground.com/aq?query=query",
dataType : "jsonp",
jsonp : "cb",
data : {
"query" : query,
"format" : "JSON",
},
success : function(data) {
$.each(data.RESULTS, function(index, value){
results.push(value.name)
})
}
});
return results;
}
おかげ
どういう意味ですか?あなたは例を挙げることができますか?ありがとう –