I am trying to build a simple test case that uses jQuery UI v10 Autocomplete to get data from a webservice, but I get this when I try to make the ajax call to the web service:
System.ArgumentException: Item has already been added. Key in dictionary: 'SetAccountProperty' Key being added: 'SetAccountProperty'
This code is adapted from [http://jqueryui.com/autocomplete/#remote-jsonp] and the only significant difference I can see is that I use a POST instead of a GET, and that is because C# .NET web services need a POST.
<fieldset>
<legend>City Lookup:</legend>
<div class="cityLookup">
<label for="city1">City1:</label>
<input id="city1" />
<label for="city2">City2:</label>
<input id="city2" />
</div>
<div>
<span id="remoteResult"></span>
</div>
</fieldset>
$(function () {
$("#city1").autocomplete({
source: function (request, response) {
$.ajax({
url: "WebServices/FLSAService.asmx/CityList",
type: "POST",
dataType: "json",
data: {
prefixText: request.term,
count: 20
},
success: function (data) {
response($.map(data.geonames, function (item) {
return {
label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName,
value: item.name
}
}));
}
});
},
minLength: 2,
select: function (event, ui) {
reportRemoveResult(ui.item ?
"Selected: " + ui.item.label :
"Nothing selected, input was " + this.value);
},
open: function () {
$(this).removeClass("ui-corner-all").addClass("ui-corner-top");
},
close: function () {
$(this).removeClass("ui-corner-top").addClass("ui-corner-all");
}
});
});