I want to use Jquery autocomplete in my web application but encounter issues. I am developing my application in ASP.NET and JQuery.
Here's the part of the Autocopmlete 'succes' function:
success: function (data) {
response($.map(data.d, function (item) {
return {
label: item.key,
value: item.value
}
}));
},
My webservice returns the following JSON:
"[{"key":"Bread","value":"3"}]"
When I run it I get Javascript error:
Uncaught TypeError: Cannot use 'in' operator to search for '42' in [{"key":"bread","value":"3"}]
It looks like that the returned JSON is not in the right format for the $.map function from what I can tell. Also the result might return several items, not just one as seen above.
Can anyone help me solve this issue.
I am using JSON as the dataType and GET as the type in the Ajax call.