jquery - 尝试使用 jquery ajax 传递对象列表
问题描述
我正在尝试将对象列表传递给 MVC 控制器方法,但我只收到一个空对象。我究竟做错了什么?
列出我要通过的列表:
coordList = [{"page":1,"xStart":118,"xEnd":481,"yStart":139,"yEnd":422},{"page":2,"xStart":74,"xEnd":379,"yStart":37,"yEnd":387},{"page":3,"xStart":128,"xEnd":349,"yStart":19,"yEnd":326}]
阿贾克斯调用:
var request = $.ajax({
type: 'GET',
url: Router.action("Api", "GetTable"),
dataType: 'json',
contentType: 'application/json; charset=utf-8',
data: JSON.stringify({ 'coords': coordList }),
});
控制器方法:
[HttpGet]
public ActionResult GetTable(List<PageCoordModel> coords)
{
.....
}
页面坐标模型:
public class PageCoordModel
{
public String page { get; set; }
public int xStart { get; set; }
public int xEnd { get; set; }
public int yStart { get; set; }
public int yEnd { get; set; }
}
谢谢你帮助我
解决方案
推荐阅读
- json - 我应该使用 JSend 来包装 json ajax 响应,还是有更标准的标准?
- java - 带有公司代理的测试容器
- php - How to find the domain is whether HTTP or HTTPS (with or without WWW) using PHP?
- css - Css我如何从inspector中找到一个css文件
- laravel - 我如何验证 Laravel 5.4 中的电子邮件列表
- opc-ua - Livetime / uniqueness of NodeId (How to manage NodeIds for dynamic nodes)
- php - Using functions.php or something instead of content-single-product.php and content-product.php
- javascript - 从 promise 返回回调的结果
- delphi - 如何限制 ftFloat 字段的小数位数?
- entity-framework - EF .net核心重新封装错误