5
検索フィールドでの自動補完にjquery-uiを使用しようとしています。検索は別のフォームフィールドの値に依存するため、ソースのコールバックを使用しています。要求が正しく送信されていることがわかります。私のリモートスクリプトは文字列の単純な配列を返し、その時点で私はそれを動作させることができません。ドロップダウンリストは作成されません。なぜ誰かが私に言うことができますか?jquery-uiオートコンプリートでのカスタムソースからのデータの処理
$(document).ready(function(){
$("#species").autocomplete({
source: function(request, response) {
$.ajax({
url: "/includes/species-ajax.cfm",
dataType: "jsonp",
data: {
term: request.term,
searchBy : function() {
var sb = $("#searchBy_hidden").val();
return (sb ? sb : 'common_name'); }
},
success: function(data) {
response($.map(data, function(item) {
return {
label: item.name,
value: item.name
}
}));
}
});
}});
});
<input type="hidden" name="searchBy_hidden" id="searchBy_hidden" value="common_name" />
Enter the name of a species: <input type="textbox" size="30" id="species" />
おかげで、
'jsonp'
ない、'json'
に変更してみてください::'成功:機能(データ){応答ここでは、コードです(データ)。 } '、 – jaybeeそれだけです!ありがとうdavin :-) – jaybee