JSON日期不张贴到控制器(KnockoutJS / JQuery的,MVC 4 RC) [英] JSON date not posting to controller (KnockoutJS/JQuery, MVC 4 RC)

查看:124
本文介绍了JSON日期不张贴到控制器(KnockoutJS / JQuery的,MVC 4 RC)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个KnockoutJS视图模型而我张贴到一个MVC控制器,像这样一个JSON对象:

I have a KnockoutJS viewmodel which I'm posting to an MVC controller as a JSON object like so:

var dataObj = ko.toJSON(viewModel);
$.post(postURL, dataObj, callBackFunc);

该模式本身具有生育领域的一个日期:
dataObj.DOB

然而,每当我的MVC控制器接收它的出生日期字段始终 12:00:00#(VB.NET)

However whenever my MVC controller receives it, the DOB field is always #12:00:00 AM# (VB.NET)

下面是我下面的控制器:

Here's my controller below:

<HttpPost()> _
    <AjaxOnly()> _
    Public Function PersonalDetails(PersonalInfo As DetailsViewModel.PersonalDetails)
        'clean the null values
        Dim newValues As Dictionary(Of String, String) = _getPropertyDict(PersonalInfo)
        Dim repo As New DetailsViewModelRepository()

    For Each entry In newValues
        repo.InsertUpdateField(PersonalInfo.MemberId, entry.Key, entry.Value)
    Next

    Return PartialView("~/Views/Home/Details/PersonalDetails.vbhtml", PersonalInfo)
End Function

我如何得到它正确地接收日期?

How do I get it to receive the date properly?

推荐答案

我尝试以下和它的工作,只是不知道浏览器的兼容性范围:

I tried the following and it worked, just not sure about the range of browser compatibility:

dataObj.DOB = dataObj.DOB.toISOString();

这篇关于JSON日期不张贴到控制器(KnockoutJS / JQuery的,MVC 4 RC)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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