如何提醒 $.ajax 获取包含日期的数据

How to alert $.ajax get data which contain date

这是我的控制器操作。 holiDays 变量包含 DateTime 数组,例如(21/03/2015 12:00:00 AM),我通过 Json 传递给视图:

 [HttpGet]
    public JsonResult GetHolydays()
    {
        var holiDays = DbFactory.Db.YearHolydays.ToList();
        return Json(new {con = holiDay},JsonRequestBehavior.AllowGet);
    }

这是我的 jquery 代码,它通过 ajax 请求获取数据:

<script>
scheduler.attachEvent("onSchedulerReady", function () {
    $.ajax({
        url: "/Customer/Customer/GetHolydays",
        dataType: "json",
        type: "GET",
        success: function (data) {
            var obj = jQuery.parseJSON(data);
            alert(obj.cenas);
            scheduler.blockTime(new Date(), "fullday");
        },
        error: function (xhr) {
            alert('error');
        }
    });
});
</script>

我想提醒返回的数据,但这对我不起作用,而且提醒不显示数据。

您的数据必须采用 Json 格式。

.....

 success: function (data) {
        alert(data);// It must be a json
        var obj = jQuery.parseJSON(data);
        alert(obj.cenas);
        scheduler.blockTime(new Date(),"fullday");
    },

...

谢谢大家做到了,这是代码:

 success: function (data) {

                var obj = data.con;

                console.log(new Date(parseInt(obj.Date.substring(6))));//I did this 
                console.log(obj.HollidayDescription);

        },