Pass a datetime from javascript to c# (Controller)

前端 未结 7 2221
小蘑菇
小蘑菇 2020-12-08 02:01

How do you pass a date time (i need it to the second) to c# using jquery and mvc3. This is what I have

var date = new Date();    
$.ajax(
   {
       type: \         


        
7条回答
  •  悲哀的现实
    2020-12-08 02:12

    The following format should work:

    $.ajax({
        type: "POST",
        url: "@Url.Action("refresh", "group")",
        contentType: "application/json; charset=utf-8",
        data: JSON.stringify({ 
            myDate: '2011-04-02 17:15:45'
        }),
        success: function (result) {
            //do something
        },
        error: function (req, status, error) {
            //error                        
        }
    });
    

提交回复
热议问题