我有一个ASP.NET MVC3应用程序,从WCF服务获取坐标列表。该服务返回一个包含一些属性(Xcoor和Ycoor)的列表。
public List<Location> GetCoordinate()
{
sensor = new Location();
List<Location> coordinateList = sensor.GetSensorInformation();
return coordinateList;
}
在我的网页中,我有一个JavaScript函数,它接受两个参数并在页面上(地图上)显示坐标。
function GetLocation(y, x){
//my code here
}
我希望从我的控制器中获取坐标列表,并将它们传递给该JS函数进行处理。如何最好地实现这一点?我尝试使用以下代码,但不知道如何解析结果:
$.ajax({
url: '@Url.Action("GetCoordinate")',
type: 'GET',
dataType: 'xml',
success: function(result) {
},
error: function (xhr, ajaxOptions, thrownError){
alert(xhr.status);
alert(thrownError);}
});
有什么想法吗?
GetCoordinatesArray
返回一个List<T>,那么jQuery的$.ajax
如何将其作为URL调用? - Only Bolivian Here