$.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);
}
})
где данные
["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));
}
, но если я ищу по слову "так", я ничего не получаю.
Если ws возвращает
[WebMethod]
public string GetSuggestedRestaurants(object prefixText)
{
return "Aeroplane dkhashd Apple Ambulance Border Crops Desalination Elephants Parrot ";
}
, а js выглядит как
data = msg.d.split(" ");
alert(data)
, тогда данные выглядят как
Aeroplane,dkhashd,Apple,Ambulance,Border,Crops,Desalination,Elephants,Parrot
и работают с автоподстановкой.Что будет с первым json, если данные
["some text","another some textz","huh just text"]