문제

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