如何在显示中显示数据:.json函数中的表格?
问题描述:
我有一个以.json功能,其获取一些数据,我想用一个<display:table>
显示它,我该怎么办呢如何在显示中显示数据:.json函数中的表格?
Alerta.js
function loadAlertaCitas(){
$.ajax({
type: "GET",
url: contextpath+"/alerta/cargaAlertas.json",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data) {
listaAlertas = data;
}
});
}
Alerta.jsp
<display:table name="listaAlertas" id="alertas"
defaultorder="descending" requestURI="/other/listaAlertas" pagesize="12"
class="table table-striped table-condensed">
<display:column property="fechaalta" titleKey="label.fechaAlta"
sortable="true" class="ancho90" />
</display:table>
答
JSP在服务器上执行。 JavaScript(在这种情况下)在浏览器中执行。
您无法使用JavaScript生成JSP标记,因为将它们转换为HTML的软件存在于错误的计算机上。
您需要改为在浏览器中操作文档的DOM。使用createElement
,createTextNode
,appendChild
和friends。
为什么你有'的contentType: “应用/ JSON的;字符集= UTF-8”,在'GET请求? GET请求中没有请求主体,因此没有任何内容类型可以描述。 – Quentin 2014-09-01 08:07:59