Pregunta

I have a js like below:

    var html=""
    $.getJson("getRelatedDynamicFields.json", { ajax: 'true'}, function (data) {
       switch(data[0].ReferenceType) {
          case "Table1":
               html += '<jsp:include page="Page1.html">';
               break;
          case "input":
                html += '<input id="' + data[0].id + '" type="text"/>';
                break; 
.
.
.
       }
    }
    $('#myDiv').html(html);

the second case works find, but the first case doesn't. I get the page with error and not loaded completely. how should I do this?

¿Fue útil?

Solución

Since you are adding html content as

jsp tag is a server side code so it won't get executed at client side.

One way to achive the same you you get the whole html of Page1.html through ajax call and place inside the div if data[0].ReferenceType is Table1. This will do the job.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top