Home  >  Article  >  Web Front-end  >  Use js to declare an array, and the object is in the jsp page (get ajax to get json data)_Basic knowledge

Use js to declare an array, and the object is in the jsp page (get ajax to get json data)_Basic knowledge

WBOY
WBOYOriginal
2016-05-16 17:17:241109browse

1. You can use the jsp tag

in the js of the jsp page

var patientInfoList={patientId:"${session.patientId}"};
var docDepList=[],noTypeMap=["","Normal number" ,"Attending physician number","Deputy chief physician number","Chief physician number"];

idx" var="list" items="${docDepList}">
docDepList [${idx.index}]={doctorId:"${list.doctorId}",departmentName:"${list.departmentName}"} ;

docDepList is an array, which can be an object in js assignment

patientInfoList is an object

2. If the value passed by ajax is

Copy code The code is as follows:

{"birthday":"1977-07-08","contactInfoList":[],"gender":"male"} can be obtained by using eval("(" data ")").birthday The value of birthday
[{"contactInfo_ID":0,"create_Time":""create_Time}] is equivalent to an array and can be obtained using 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;ialert(dataArr[i].create_Time);


}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn