ajax - 如何将 int 数组从 ajax 发送到 c# mvc?

标签 ajax asp.net-mvc arrays jquery asp.net-ajax

如何将 int 数组从 $.ajax 发送到 c# mvc?

最佳答案

$.ajax({
          url: <Url of the action>,
          type: "POST",
          data: JSON.stringify([1,2,3]),
          dataType: "json",
          contentType: 'application/json; charset=utf-8'
});

并在行动中。

public ActionResult ReceiveIntArray(int[] ints)
{
   ...
}

mvc 应该自动解析 json。

查看 this question.

关于ajax - 如何将 int 数组从 ajax 发送到 c# mvc?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9109544/

相关文章:

ajax - 剑道网格 : combobox field from json data

php - 如何从 CS 购物车中的 tpl 文件向 Controller 后端 php 文件发送 ajax 请求?

asp.net-mvc - HTML5 元素 'legend' 出现次数太少

javascript - 如何在鼠标滚动上加载消息?

php - 如何从 db 表、php 数组或 JSON 中获取分层 php 结构

c - 合并排序实现中的段错误

javascript - 选择文件后立即上传图像

ajax - 更改jquery中的缓存时间

php - 我如何获取从一个页面到另一个重定向页面的数组ID

c# - 如何传递要包含在 URL 中的参数?