相关疑难解决方法(0)

将日期值从Ajax调用传递给MVC

我的Ajax电话

 $('#QuickReserve').click(function () {
        var now = new Date();
        alert(now);

        var _data = {
            'ComputerName': _computerName,
            '_mStart': now.toTimeString(),
            '_mEnd': now.toDateString()
        };
        $.ajax({
            cache: false,
//            contentType: "application/json; charset=utf-8",
            type: "POST",
            async: false,
            url: "/Home/SetMeeting",
            dataType: "json",
            data: _data,
            success: "",
            error: function (xhr) {
                alert("Error");
                alert(xhr.responseText);
            }
        });
    });
Run Code Online (Sandbox Code Playgroud)

我的C#代码

 public ActionResult SetMeeting(string ComputerName, DateTime? _mStart, DateTime? _mEnd)
        {
           }
Run Code Online (Sandbox Code Playgroud)

代码结束时未收到DateTime值.....它们只显示为空白.在jquery当我试图

'_mStart': now.toTimeString(),
            '_mEnd': now.toDateString()
Run Code Online (Sandbox Code Playgroud)

到datetring确实返回今天的日期,但是,我也希望时间也是日期时间的一部分.

c# asp.net-mvc jquery asp.net-mvc-3

33
推荐指数
2
解决办法
6万
查看次数

标签 统计

asp.net-mvc ×1

asp.net-mvc-3 ×1

c# ×1

jquery ×1