SyntaxError: missing] after list of items in jquery

I want to assign an object to the list items of StudentDetailsVo.

I get this error.

 $("#searchAtten").click(function(){
            $("#tablerows").empty();
            var sectionId=$("#selSection :selected").attr("id");
            var studid=$("#studentid").val();
            var datee = ${resultVO.monthEndDate}
            var reqD = ${resultVO.reqdEndDate}
            //I need to assign object here 
            var namem =${resultVO.studentList}
            alert("namem"+namem);
            var betweentDate=  reqD-datee;
            alert("betweentDate = "+betweentDate);
            for(var i=1;i<=datee;i++){
                alert(i);
                $("#tableRows tr").append('<th width="129" scope="col"  style="text-align: center;">'+i+'</th>'); 
            } 
             if(sectionId == undefined)
                {
                sectionId = "null";
                }
             if(studid == "")
            {
                studid = "null";
            } 
                fetch_atten(sectionId,studid);          
                });
    });

I take these values ​​from VO files:

<% if (session.getAttribute("resultVO") != null){
     AttendanceResultVO resultVO= (AttendanceResultVO)session.getAttribute("resultVO");
         } 
%>

**> Error of my error:

SyntaxError: missing ] after element list
[Break On This Error]     

var namem =[com.sfmfm.vo.StudentDetailsVO@487c5f]

myschool.jsp (line 53, col 43)**
+1
source share
2 answers

If you look at column 43, you are at '@'. Use

var namem = ['com.sfmfm.vo.StudentDetailsVO@487c5f'];

although the text is unusable toString, which is no longer displayed on the object itself, I'm afraid.

To minimize, by removing unnecessary spaces / newlines, I would leave it at semicolons.

+1
source

I suggest you do this:

        var datee = <%=resultVO.monthEndDate}%>;
        var reqD = <%=resultVO.reqdEndDate%>
        var namem =<%=resultVO.studentList%>

instead of this

       var datee = ${resultVO.monthEndDate}
        var reqD = ${resultVO.reqdEndDate}
        //I need to assign object here 
        var namem =${resultVO.studentList}
0
source

Source: https://habr.com/ru/post/1609899/


All Articles