您如何使用jquery和mvc3将日期时间(我需要第二个)传递给c#。这就是我所拥有的
var date = new Date(); $.ajax( { type: "POST", url: "/Group/Refresh", contentType: "application/json; charset=utf-8", data: "{ 'MyDate': " + date.toUTCString() + " }", success: function (result) { //do something }, error: function (req, status, error) { //error } });
我无法弄清楚日期应采用哪种格式,以便C#理解。
以下格式应该可以工作:
$.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 } });