Use js to declare an array. The object is on the jsp page (obtain json data from ajax)

Source: Internet
Author: User

1. jsp labels can be used in jsp page js

Var patientInfoList = {patientId: "$ {session. patientId }"};
VarDocDepList = [], NoTypeMap = ["", "General", "attending doctor", "Deputy Chief Physician", "Chief Physician"];

<C: forEach varStatus ="Idx"Var =" list "items =" $ {docDepList} ">
 DocDepList[$ {Idx. index}] = {DoctorId: "commandid list.doc torId}", departmentName: "$ {list. departmentName }"};
</C: forEach>

DocDepListIs an array, and the js value assignment can be an object.

PatientInfoListIs an object

2. If the value passed by ajax is
Copy codeThe Code is as follows:
{"Birthday": "1977-07-08", "contactInfoList": [], "gender": "male"} can use eval ("(" + data + ")"). returns the value of birthday.
[{"ContactInfo_ID": 0, "create_Time": "" create_Time}] is equivalent to an array. You can use eval ("(" + data + ")") [0]. get 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 );


}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.