Saturday, November 17, 2012

c# – JQuery Autocomplete won't load remote values

Okay, so JQuery\’s autocomplete widget is driving me nutz!

I have tried numerous ways of loading the widget. I am currently getting the following:



Error: jQuery15105511000803127266_1353087819681 was not called -

parsererror



and the Response value (from firebug) appears to be System.string[] though I\’m not sure if it\’s an a string who\’s value is System.string[] or an actual system.string[] object.


Am I just being stupid, or am I missing something (please be kind in your answer to that last question…)?


My javascript is:



$(\"#clientName\").autocomplete({
source: function (request, response) {
$.ajax({
url: \"/supplier/apSupplierSearch/\",
data: { searchAPName: clientName.value },
dataType: \"json\",
type: \"POST\",
success: function (data) {
//response(data);
response($.map(data, function (item) {
return {
label: item.Name,
value: item.Name
}
}))
}
}); // ajax
}, // function [{
scroll: true,
scrollHeight: 600,
minLength: 4
});


My WebMethod is:



[WebMethod]
public string[] apSupplierSearch(string searchAPName)
{
IList<int> selectedPropertyIDs = new List<int>();
string currentRole = UserServices.GetCurrentRole();
Property currentProperty = UserServices.GetCurrentPropety();
List<ApSupplier> suppliers = ApSupplierQueries.GetApSuppliers(searchAPName, selectedPropertyIDs, currentRole, currentProperty);
List<string> supplierList = new List<string>();
foreach (ApSupplier supplier in suppliers)
{
supplierList.Add(supplier.Name);
}
return supplierList.ToArray();
}






Rating: 2 out of 5 based on 3 ratings



The post c# – JQuery Autocomplete won't load remote values appeared first on Javascript ASK.






via Javascript ASK http://javascriptask.phpfogapp.com/c-jquery-autocomplete-wont-load-remote-values.html

No comments:

Post a Comment