我正在尝试在 MVC3 中使用 AJAX 动态加载表。为什么这只能在 IE9 的兼容模式下工作?有办法解决吗?
看法:
<script src="../../Scripts/jquery-1.5.1.js" type="text/javascript"></script>
<script src="../../Scripts/jquery-ui-1.8.11.js" type="text/javascript"></script>
<script type="text/javascript">
$.ajax({
type: 'POST',
url: "/Index/GetApplicationsForUserJSON",
success: function (data) {
for (var i = 0; i < data.length; i++) {
$("#ApplicationsForUser tbody").append("<tr>" +
"<td>" + data[i].Application + "</td>" +
"<td>" + data[i].Roles + "</td>" +
"</tr>");
}
$("tr:odd").css({ 'backgroundColor': '#ebf0f5' });
}
});
</script>
<table id="ApplicationsForUser" class="ui-widget ui-widget-content" style="width: 99%;
margin: 3px 0px 0px 3px">
<thead>
<tr class="ui-widget-header ">
<th style="width: 45%">
Application
</th>
<th style="width: 45%">
Roles
</th>
</tr>
</thead>
</table>
控制器:
public JsonResult GetApplicationsForUserJSON()
{
Dictionary<string, string> tableData = new Dictionary<string, string>();
tableData.Add("row1", "row1data");
var jsonData = tableData
.Select(c => new
{
Application = c.Key,
Roles = c.Value
});
return Json(jsonData, JsonRequestBehavior.AllowGet);
}
编辑:图片!