将json数据传递给自动完成多选jquery的源时遇到问题 这是我发送的杰森数据
[ "abhinav@sdv.com","nishimura@dscs.com","alex@sds.com","alice@sdvs.com","amit@sds.com"]
autocomplete: {
source: function (request, response) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "/CommanService.asmx/ExtractEmail",
data: {},
dataType: "json",
success: function (data) {
var vServiceData = eval(data);
// alert(data.d[0].data123);
//return eval('[' + data.d + ']');
//response(vServiceData);
// alert(data);
response(data);
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(xhr.responseText);
alert(thrownError);
}
})
}
在这个ajax的来源中,但这里的问题是,而不是获得这些记录 不同的字符串输出是单字符串的形式,但当我传递静态数据,如
source = [“Red”,“blue”,“green”]
我的网络服务代码是
#region(EXTRACT EMAIL)
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
[WebMethod]
public string ExtractEmail()
{
//Webservice is used to extract the employee data
VisualLibrarySoapClient oVisualLibrary = new VisualLibrarySoapClient();
string data = oVisualLibrary.EmployeeSelectData();
DataSet ds = new DataSet();
ds = GetDataSet(data);
//Used data columns to extract email from data set
DataColumn ColEmail = ds.Tables[0].Columns["Email"];
//all emails are stored in a linst Mail
List<string> Mail = new List<string>();
foreach (DataRow row in ds.Tables[0].Rows)
{
String MailData = row[ColEmail].ToString();
Mail.Add(MailData);
}
//Json serializer is used to convert the list data into jason format
//System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
// string a = JsonConvert.SerializeObject(Mail);
string ss = JsonConvert.SerializeObject(Mail, Formatting.Indented);
string d = ss.Substring(1, ss.Length - 1).ToString();
return ss;
//System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
//return serializer.Serialize(Mail);
}
#endregion
直接在源代码然后输出是正确的我在自动完成文本框中提示这三个单词提示plzz帮助thanx提前