JSON Simple Instance

Source: Internet
Author: User

1.html:

<! DOCTYPE html>

 2.js

Browser protocol var xmlhttp;function creatxmlhttprequest () {if (window.xmlhttprequest) {xmlhttp=new XMLHttpRequest ();} else if (window. ActiveXObject) {xmlhttp=new XMLHttpRequest ("Microsoft,xmlhttp");}} The Trigger function Functions Student2 () {alert ("AA");//Establish an asynchronous Request object Creatxmlhttprequest ();//Turn on the server-side connection Xmlhttp.open ("Post", " Student2.txt ", true);//Send request to Browser xmlhttp.send ();//Call callback function Xmlhttp.onreadystatechange=getstudent2;} function GetStudent2 () {//Determine request status if (xmlhttp.readystate==4&&xmlhttp.status==200) {//server response var msg= Xmlhttp.responsetext;var Stus=eval ("(" +msg+ ")"); Tbody=document.getelementbyid ("main"); for (Var i=0;i< stus.length;i++) {var stuno=stus[i].stuno;var name=stus[i].name;var Age=stus[i].age;var address=stus[i].address;tr= Document.createelement ("tr"); Td1=document.createelement ("TD"); Td1.innerhtml=stuno;tr.appendchild (TD1); td2= Document.createelement ("TD"); Td2.innerhtml=name;tr.appendchild (TD2); Td3=document.createelement ("TD"); Td3.innerhtml=age;tr.appendchild (TD3); Td4=document.createelement ("TD"); Td4.innerhtml=addreSs;tr.appendchild (TD4); Tbody.appendchild (tr);}}} 

3.txt

[
{"Stuno": "001", "Name": "Jack", "age": All, "Address": "Beijing"},
{"Stuno": "002", "name": "Bob", "Age": "Address": "Shanghai"},
{"Stuno": "003", "name": "Mary", "age": +, "address": "Anerick"},
{"Stuno": "004", "name": "Kity", "age": +, "address": "Hongkong"}
]

JSON Simple Instance

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.