jQuery UI autocomplete XML Source Value and display members?

hoffmanfrog

New Member
I'm trying to retrieve cities for an input text for suggestions to user.But I need to have a display value for user, and a hidden id for the script.I got my response in XML format like this :\[code\]<response state="true" reason="success"> <city id="4654">75000 Paris</city> <city id="4784">78100 St germain</city> ...</response>\[/code\]I actually have this in the source property of .autocomplete() :\[code\]var cities = $(result).find("city").map(function(){ return { id: $(this).attr("id"), displayValue: $(this).text() };}).get();response(cities);\[/code\]
This is not working. I got : "Unexpected token this"
Does anyone know how to do this ?EDIT : also tried this\[code\]var cities = $("city", result).map(function() { return { id: $("city", this).attr("id"), displayValue: $("city", this).text() }; }).get();\[/code\]and no more success
 
Back
Top