var dataObj = { PlanId: 111, PlanUserid: $(this).children(".easyui-combobox").eq(0).combobox("getValue"), PlanWeight: $(this).children(".easyui-numberbox").eq(0).val(), PlanTask: $(this).children(".easyui-numberbox").eq(1).val(), Deletemark:1, PlanCustomer: $(this).children(".easyui-numberbox").eq(2).val(), PlanData: planData } dataArr.push(JSON.stringify(dataObj)); $.ajax({ url: "@Url.Action("Save")", data: { SaveDataList: dataArr }, traditional: true, type: "post", success: function (data) { if (data.Flag) { alert("保存成功"); $("#integralDataGrid").datagrid("reload"); $('#PMWindow').dialog('close'); } else { alert(data.ErrMsg); } } })
[HttpPost] public JsonResult Save(DataPlanVO vo) { return Json(vo.DataList, JsonRequestBehavior.AllowGet); } [Serializable] public class SaveDataPlanVO { private long _planId; /// <summary> /// /// </summary> public long PlanId { get { return _planId; } set { _planId = value; } } private long? _planUserid; /// <summary> /// /// </summary> public long? PlanUserid { get { return _planUserid; } set { _planUserid = value; } } private DateTime? _planDate; /// <summary> /// /// </summary> public DateTime? PlanDate { get { return _planDate; } set { _planDate = value; } } private decimal? _planWeight; /// <summary> /// /// </summary> public decimal? PlanWeight { get { return _planWeight; } set { _planWeight = value; } } private long? _planTask; /// <summary> /// /// </summary> public long? PlanTask { get { return _planTask; } set { _planTask = value; } } private long? _planCustomer; /// <summary> /// /// </summary> public long? PlanCustomer { get { return _planCustomer; } set { _planCustomer = value; } } private long? _deletemark; /// <summary> ///0: 删除,1:正常,2:停用 /// </summary> public long? Deletemark { get { return _deletemark; } set { _deletemark = value; } } private DateTime? _modifydate; /// <summary> /// /// </summary> public DateTime? Modifydate { get { return _modifydate; } set { _modifydate = value; } } }
Save方法里的VO有一个List<SaveDataPlanVO>
我AJAX提交的数据~但是后台只能序列化出对象数量,具体的数据全是NULL
没有关键代码啊 贴出来的是我AJAX提交的内容
后台直接用的一个LIST去接收
你不给代码,谁都难给你解答。
贴关键代码
看一下你的success回调函数
应该List接收不了,用string接收,再去解析下?
1.看请求报文格式
2.看接收到的请求报文格式
3.看请求报文是否能被正确解析成你指定的类型
4.问题解决
我怎么回答说,话说服务端能接收list吗?
没代码就有点恼火了,看下Name值是不是对应上了的~或者序列字段是不是区别大小写
代码
思路对的,没有值就多调试吧
加上属性 [DataMember],如下
/// <summary> /// /// </summary>
[DataMember]
public long PlanId
{
get { return _planId; }
set { _planId = value; }
}