I am using a jQuery Autocomplete but it is returning all the XML entries as one list item instead of one item/keyword
Here is my sample XML
<keywords>
<keyword>Hello</keyword>
<keyword>asdfasd</keyword>
<keyword>fsdgs</keyword>
<keyword>Helqerqlo</keyword>
<keyword>Hello</keyword>
<keyword>Hello</keyword>
<keyword>shjfg</keyword>
<keyword>zcxvv</keyword>
<keyword>Hello</keyword>
<keyword>fjhfhg</keyword>
<keyword>Hello</keyword>
<keyword>fdgs</keyword>
<keyword>gfhdgh</keyword>
<keyword>sdfgsdf</keyword>
<keyword>dfghd</keyword>
<keyword>xvcb</keyword>
<keyword>dfghdgh</keyword>
<keyword>Heldfghdglo</keyword>
</keywords>
And the jQuery:
$(document).ready(function(){
$.ajax({
url: "xml1.xml",
dataType: "xml",
success: function( xmlResponse ) {
var data = $( "keywords", xmlResponse ).map(function() {
return {
value: $( "keyword", this ).text()
};
}).get();
$('#ctl00_MainContentPlaceHolder_txtSchool').autocomplete({
source: data,
minLength: 0
});
}
});
});
And here is the only option in the autocomplete drop down list (all keywords mashed together as one long keyword)
HelloasdfasdfsdgsHelqerqloHelloHelloshjfgzcxvvHellofjhfhgHellofdgsgfhdghsdfgsdfdfghdxvcbdfghdghHeldfghdglo
Any help is appreciated.
Thanks,
Thomas
Your problem is
the text() is returning the innerText of the keyword… simples
you should just return: