我试图获取输入项字母表自动填充列表,但是当我想搜索它显示在控制台内的内容时
<块引用>无法读取未定义的属性“toLowerCase”
这是我的代码,我想通过它来填充下拉搜索项
// Do the actual search
function run_search(query) {
var cache_key = query + computeURL();
var cached_results = cache.get(cache_key);
if (cached_results) {
if ($.isFunction($(input).data("settings").onCachedResult)) {
cached_results = $(input).data("settings").onCachedResult.call(hiddenInput, cached_results);
}
populateDropdown(query, cached_results);
} else {
// Are we doing an ajax search or local data search?
if ($(input).data("settings").url) {
var url = computeURL();
// Extract existing get params
var ajax_params = {};
ajax_params.data = {};
if (url.indexOf("?") > -1) {
var parts = url.split("?");
ajax_params.url = parts[0];
var param_array = parts[1].split("&");
$.each(param_array, function(index, value) {
var kv = value.split("=");
ajax_params.data[kv[0]] = kv[1];
});
} else {
ajax_params.url = url;
}
// Prepare the request
ajax_params.data[$(input).data("settings").queryParam] = query;
ajax_params.type = $(input).data("settings").method;
ajax_params.dataType = $(input).data("settings").contentType;
if ($(input).data("settings").crossDomain) {
ajax_params.dataType = "jsonp";
}
// exclude current tokens?
// send exclude list to the server, so it can also exclude existing tokens
if ($(input).data("settings").excludeCurrent) {
var currentTokens = $(input).data("tokenInputObject").getTokens();
var tokenList = $.map(currentTokens, function(el) {
if (typeof $(input).data("settings").tokenValue == 'function')
return $(input).data("settings").tokenValue.call(this, el);
return el[$(input).data("settings").tokenValue];
});
ajax_params.data[$(input).data("settings").excludeCurrentParameter] = tokenList.join($(input).data("settings").tokenDelimiter);
}
// Attach the success callback
ajax_params.success = function(results) {
cache.add(cache_key, $(input).data("settings").jsonContainer ? results[$(input).data("settings").jsonContainer] : results);
if ($.isFunction($(input).data("settings").onResult)) {
results = $(input).data("settings").onResult.call(hiddenInput, results);
}
// only populate the dropdown if the results are associated with the active search query
if (input_box.val() === query) {
populateDropdown(query, $(input).data("settings").jsonContainer ? results[$(input).data("settings").jsonContainer] : results);
}
};
// Provide a beforeSend callback
if (settings.onSend) {
settings.onSend(ajax_params);
}
// Make the request
$.ajax(ajax_params);
} else if ($(input).data("settings").local_data) {
// Do the search through local data
var results = $.grep($(input).data("settings").local_data, function(row) {
return row[$(input).data("settings").propertyToSearch].toLowerCase().indexOf(query.toLowerCase());
});
cache.add(cache_key, results);
if ($.isFunction($(input).data("settings").onResult)) {
results = $(input).data("settings").onResult.call(hiddenInput, results);
}
populateDropdown(query, results);
}
}
}