c# - Autocomplete textbox with xml source not working -
i have web service returns list of strings. trying feed datasource auto suggesttextbox. here webservice returns
<arrayofstring> <string>air pollutants</string> <string>air facilities</string> <string>air emissions</string> <string>air pollution</string> <string>air quality monitoring</string> <string>air piracy</string> </arrayofstring>
this jquery ajax.
$(document).ready(function () { $('#<%=txt_search_extantdata.clientid%>').autocomplete({ source: function (request, response) { $.ajax({ type: 'post', url: "/_layouts/extantlibrarywebservice/getdata.asmx/getsearchdata", data: { 'src': $("#<%=txt_search_extantdata.clientid%>").val() }, datatype: "xml", success: function (xmlresponse) { response($(xmlresponse).map(function () { return { value: $(this).text() }; })) }, error: function (xmlhttprequest, textstatus, errorthrown) { alert(textstatus); } }); }, minlength: 2 }); });
what gettting output 1 single item strings attached
air pollutantsair facilitiesair emissionsair pollution air quality monitoringair piracy
what want display in out put 1 string in 1 line
air pollutants airfacilities air emissions air pollution air quality monitoring air piracy
i not able figure out doing wrong please...
ok figured out , success callback should :
success: function (xmlresponse) { response($("string", xmlresponse).map(function () { return { value: $(this).text() }; })); },
because here getting response contains xml node of string inside arrayofstrings selector map inside response should this
$("string", xmlresponse)
hope helps !!
Comments
Post a Comment