我承认,这是一个非常基本的问题。但我实际上厌倦了它。我只是想将我的当前时间以 JSON 格式从我的操作方法发送到视图。在视图代码中,我尝试使用 jQuery ajax() 方法获取结果。但是在成功属性中,我无法从响应中获取结果。尝试了多种方法,例如 response.d 等,但几乎一无所获。
下面是相关的代码片段:
动作方法:
 public JsonResult GetDateTest()
        {
            return Json(DateTime.Now.ToString(), JsonRequestBehavior.AllowGet);
        }
视图中的脚本:
<script type="text/javascript">
    $(document).ready(function () {
        $("#Button1").click(function (e) {
            $.ajax({
                type: 'POST',
                url: '@Url.Action("GetDateTest","GetDate")',
                data: '{}',
                contentType: 'application/json; charset=utf-8',
                dataType: 'json',
                success: function (response) {
                    //how can I read the date here and display it on the standard //controls like a label?
                },
                error: function (e) {
                    alert("error");
                }
            });
        });
    });
</script>
用正确的解释帮助我弄清楚