使用jQuery提交对象数组 [英] Submit array of objects using jquery

查看:108
本文介绍了使用jQuery提交对象数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否存在用于通过jquery发布对象数组的内置解决方案?

Is there any built-in solution for posting array of objects, through jquery?

数组是

data = [{
  id: "333",
  date: "22/12/2015"
 },
{
  id: "333",
  date: "22/12/2015"
 }]

$.post('url', data, function(){}, "json");失败

推荐答案

您可以发送包含如下数组的对象:

You can send an object that contains the array like this:

data = {
    items: [{
      id: "333",
      date: "22/12/2015"
    },
    {
      id: "333",
      date: "22/12/2015"
    }]
}

$.post('url', data, function(){}, "json");

这篇关于使用jQuery提交对象数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆