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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top