0

I have a .json function whose retrieve some data and I want to show it with a <display:table>, how can I do it

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>
Raider
  • 394
  • 1
  • 2
  • 26
  • Why do you have `contentType: "application/json; charset=utf-8",` in a GET request? There is no request body in a GET request so there is nothing to describe the content-type of. – Quentin Sep 01 '14 at 08:07

2 Answers2

0

JSP is executed on the server. JavaScript (in this context) is executed in the the browser.

You can't generate JSP tags with JavaScript because the software that converts them into HTML exists on the wrong computer.

You need to manipulate the DOM of the document in the browser instead. Use createElement, createTextNode, appendChild and friends.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
0

You can do it on the server side. Read the json file and load display:table within the render method for jsp template:

request.setAttribute('listaAlertas', jsonData);

More info.

If you insist on loading dynamically from the browser, you need to manipulate dom as suggested. In that case you can't use display:table as it is rendered on the server.

More info

Community
  • 1
  • 1
user3995789
  • 3,452
  • 1
  • 19
  • 35