问题
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