I have a missing semicolon per JSLint
My JS code:
$("#1").autocomplete(
{
source: function (request, response)
{
"use strict";
$.ajax(
{
url: "http://www.domain.com/foo/",
dataType: "jsonp",
data: {
api_key: "123",
search_term: request.term
},
success: function (data)
{
response($.map(data.data, function (item)
{
return {
label: item.username,
value: item.user_id
}
}));
}
});
},
minLength: 2
});
JSLint gives me the following error:
Error:
Problem at line 21 character 9: Expected ';' and instead saw '}'.
}
I don't see where this semicolon shoul开发者_如何学Pythond go. What am I not seeing? The code works when I tested it.
It wants it here;
return {
label: item.username,
value: item.user_id
}; <--
return {
label: item.username,
value: item.user_id
};
return {
label: item.username,
value: item.user_id
}
should read
return {
label: item.username,
value: item.user_id
};
Your ; needs to go after the return{} block. Consider using something like Notepad++ to pinpoint line numbers.
精彩评论