如何使用 ajax 返回 IEnumerable 的值。这是我的脚本:
$.ajax({
type: "get", url: "street", data: { a: value2 },
success: function (data) {
alert(data);
}
这是我的控制器方法:
[HttpGet]
public string street(string a)
{
EmlakServicesClient client = new EmlakServicesClient();
client.ClientCredentials.UserName.UserName = "service_test";
client.ClientCredentials.UserName.Password = "..";
client.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.None;
Street[] list =client.GetStreet(Convert.ToInt32(a));
return ("" + list.FirstOrDefault().StreetName);
}
正如您在顶部看到的那样,我得到了价值,但有了第一个价值,那么我怎样才能从 IEnumarable 获得这些所有值?