I'm trying to create an autocomplete text box using VB .Net4. It has a json back-end that simply returns a first name and last name, like so:
{"d":"[{\"firstN\":\"john\",\"lastN\":\"doe\"},{\"firstN\":\"another \",\"lastN\":\"dude\"},{\"firstN\":\"dsaf\",\"lastN\":\"asdfasdf\"}]"}
My JQuery seems like a pretty standard bit of code:
$("#MainContent_autocomplete").autocomplete({
source: function (request, response) {
$.ajax({
url: "/PatientLookup.asmx/LookupPatient",
dataType: "json",
type: "POST",
data: "{ 'key': '" + request.term + "' }",
contentType: "application/json; charset=utf-8",
processData: true,
success: function (data) {
response($.map(data.d, function (item) {
return {
label: item.firstN,
value: item.firstN
}
}));
}
});
},
minLength: 2
});
The problem occurs in the success function. When it gets inside the map function it simply will not let me read the firstN and lastN data.