Using the js declaration array the object in the JSP page of ajax to obtain json data

  • 2020-03-26 23:03:32
  • OfStack

1, in the JSP page js can use JSP tags

Var patientInfoList = {patientId: "${session. PatientId}"};
var DocDepList = [] ,noTypeMap=[""," "ordinary "," attending physician "," deputy chief physician "," chief physician "];

< C: forEach varStatus =" Independence idx "Var =" list "items =" ${docDepList} ">
  docDepList [ . ${independence idx index} ] = {doctorId: "${list. DoctorId}", departmentName: "${list. DepartmentName}"};
< / c: forEach>

docDepList It's an array, and it can be an object inside the js assignment

patientInfoList It's an object

2. If the value passed from ajax is

{"birthday":"1977-07-08","contactInfoList":[],"gender":" male "} The form can be used eval("("+data+")").birthday To obtain birthday The value of the 
[{"contactInfo_ID":0,"create_Time":""create_Time}] The form is equivalent to an array that can be used eval("("+data+")")[0].create_Time get 
var dataArr=eval("("+data+")" ); 
for(var i=0;i<dataArr.length;i++){


Related articles: