1、在jsp頁面的js中可以用jsp標簽
var patientInfoList={patientId:"${session.patientId}"};
var docDepList=[],noTypeMap=["","普通號","主治醫生號","副主任醫師號","主任醫師號"];
<c:forEach varStatus="idx" var="list" items="${docDepList}">
docDepList[${idx.index}]={doctorId:"${list.doctorId}",departmentName:"${list.departmentName}"};
</c:forEach>
docDepList是一個數組,在js賦值是裡邊可以是對象
patientInfoList是一個對象
2、如果ajax傳過來的值是
復制代碼 代碼如下:
{"birthday":"1977-07-08","contactInfoList":[],"gender":"男"}形式可以用eval("("+data+")").birthday獲得birthday的值
[{"contactInfo_ID":0,"create_Time":""create_Time}]形式相當於一個數組可以用eval("("+data+")")[0].create_Time得到
[{"contactInfo_ID":0,"create_Time":""create_Time},{"contactInfo_ID":0,"create_Time":""create_Time}],{"contactInfo_ID":0,"create_Time":""create_Time},{"contactInfo_ID":0,"create_Time":""create_Time}]
var dataArr=eval("("+data+")");
for(var i=0;i<dataArr.length;i++){
alert(dataArr[i].create_Time);
}