mvc2 中如何把 controller中的json传递到view (view用到了 jquery easyui)?
我新建了一个项目在controller 如下面:
public ActionResult About()
{
var result = new { ID = 1, Name = "linfei", Phone = "12345678", Password = "12345", Mail = "wenfeizhang@153.com", CreateTime = "2014-01-01", Address = "shenzhen" };
return Json(result, JsonRequestBehavior.AllowGet);
}
// 上面的view的界面就会弹出一下载文本的框框,
public ActionResult Testing1()
{
var result = new { ID = 1, Name = "linfei", Phone = "12345678", Password = "12345", Mail = "wenfeizhang@153.com", CreateTime = "2014-01-01", Address = "shenzhen" };
return Json(result,"text/html", JsonRequestBehavior.AllowGet);
}
//上面的return会把result 以字符串显示出来,但是没有easyui的效果
public ActionResult Testing()
{
var result = new { ID = 1, Name = "linfei", Phone = "12345678", Password = "12345", Mail = "wenfeizhang@153.com", CreateTime = "2014-01-01", Address = "shenzhen" };
return View();
}
//return view 的时候会显示出easyui的效果,但是不能把result传递到view上面
//我的view如下:
<%@ Page Title="" Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<head id="Head1" runat="server">
<meta name="viewport" content="width=device-width" />
<title>用户管理</title>
<link href="../../Scripts/easyui/themes/default/easyui.css" rel="stylesheet" type="text/css" />
<link href="../../Scripts/easyui/themes/icon.css" rel="stylesheet" type="text/css" />
<script src="../../Scripts/easyui/jquery.min.js" type="text/javascript"></script>
<script src="../../Scripts/easyui/jquery.easyui.min.js" type="text/javascript"></script>
<script src="../../Scripts/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script>
$(function () {
initTable();
});
//初始化表格
function initTable() {