$.ajax({
type: "POST",
url: "/webservices/AutoSuggestWebService.asmx/GetSuggestedRestaurants",
data: "{'prefixText': '" + $('#ctl00_ctl00_cplMPBody_txtSearch').val() + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
data = msg.d;
alert(msg.d)
$("#ctl00_ctl00_cplMPBody_txtSearch").autocomplete(data);
}
})
where data is
["some text","another some textz","huh just text"]
WS:
[WebMethod]
public string GetSuggestedRestaurants(object prefixText)
{
JavaScriptSerializer js = new JavaScriptSerializer();
string json = js.Serialize(new RestaurantSearchHelper(DaoFactory).GetSearchSuggest(prefixText.ToString(), PageBase.CurrentCountry));
}
but if i search by word "so" i don't get anything.
If ws return
[WebMethod]
public string GetSuggestedRestaurants(object prefixText)
{
return "Aeroplane dkhashd Apple Ambulance Border Crops Desalination Elephants Parrot ";
}
and js looks like
data = msg.d.split(" ");
alert(data)
then data looks like
Aeroplane,dkhashd,Apple,Ambulance,Border,Crops,Desalination,Elephants,Parrot
and autosuggest work. What is worng with first json if data is
["some text","another some textz","huh just text"]