SyntaxError: missing ] after element list in jquery

╄→尐↘猪︶ㄣ 提交于 2020-01-05 04:13:50

问题


i want to assign object for StudentDetailsVo List items.

i am keep getting 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 am taking this values from VO Files :

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

**> my fire bug error is :

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

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

myschool.jsp (line 53, col 43)**

回答1:


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

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

though the text is a unusable toString, not anymore mappable on the object itself, I fear.

For minification, removing unnecessary whitespace/newlines, I would leave in semicolons.




回答2:


I wolud suggest you to do like this

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

instead of like this

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


来源:https://stackoverflow.com/questions/14875776/syntaxerror-missing-after-element-list-in-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!