I'm using jquery.autocomplete.js, and the following JS:
$("#Search").autocomplete("/uk/Search/AutoComplete",
{
dataType: 'json',
parse: function (data) {
var rows = new Array();
for (var i = 0; i < data.length; i++) {
rows[i] = { data: data[i], value: data[i].Tag, result: data[i].Tag };
}
return rows;
}, max: 20,
formatItem: function (row, i, max) {
return row.Tag;
},
width: 300,
minChars: 4,
highlight: false,
multiple: false
});
This all works fine, and I can see that there is a server round-trip going on, and the result I e开发者_高级运维xpect is in the data
variable.
The problem I have is that I can see in the FireFox Error Console that there is an error stating s is undefined
.
It's failing on the following:
$.Autocompleter.Cache = function(options) {
var data = {};
var length = 0;
function matchSubset(s, sub) {
if (!options.matchCase)
s = s.toLowerCase(); // this is where it fails
var i = s.indexOf(sub);
if (options.matchContains == "word") {
i = s.toLowerCase().search("\\b" + sub.toLowerCase());
}
if (i == -1) return false;
return i == 0 || options.matchContains;
};
Why would this be failing? Is there anything I can do to fix it?
Most of the time...
When I get the message "[something] is undefined" it is because my JSON response object(s) contains an illegal character in the JSON or the JSON isn't formatted correctly...making the object return as undefined.
Please post your JSON so we can look further.
精彩评论