I have ASP.Net webservice being called in JQuery and the response in the drop down comes in JSON format. Below is the snippet
$(document).ready(function () {
$("#txtTest").autocomplete({
source: function (request, response) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Webservice.asmx/GetNames",
data: "{'prefix':'" + request.term + "'}",
dataType: "json",
async: true,
success: function (data){
response($.map(data, function(item)
{
/*Below commented return has to display the First item alone in JSON which fails*/
//return { label: item.First, value: item.First }
/* Below return gives the JSON response with first and second*/
return item ;
}));
},
error: function (result) {
alert("Due to unexpected errors we were unable to load data");
}
});
},
minLength:2
});
});
And the JSON response on the drop of auto-complete comes as
{"First":"Steve","Second":"AK"}
{"First":"Evet","Second":"EV"}
{"First":"Stevens","Second":"SV"}
How do i display the "First" items alone (Like Steve, Evet, Stevens) as the output of the drop down auto-complete?
Please help me!