Technical Exchange, DH explanation.
I am not engaged in web, so today's things should be quite simple.
A friend needs to implement this function.
Click More to obtain data from the server, and then display the data in the table.
I spent an hour writing an example. Here is an ugly look:
<Script language = "JavaScript"> // clear the table and pass in the table variable (DOM) function cleartable (t) {While (T. rows. length) {T. deleterow (0) ;}/// load string s to table t to function loadxml2table (S, T) {try {// ie xml = new activexobject ("Microsoft. xmldom "); XML. async = "false"; XML. loadxml (s);} catch (e) {try {// FF parser = new domparser (); xml = parser. parsefromstring (S, "text/XML");} catch (e) {alert ("XML cannot be loaded"); Return ;}// cleartab Le (t); // insert var x = xml. getelementsbytagname ("hh") for (I = 0; I <X. length; I ++) {newrow = T. insertrow (I); newrow. id = I; // X [I]. getelementsbytagname ("artist") [0]. childnodes [0]. nodevalue Newcell = newrow. insertcell (0); Newcell. innerhtml = x [I]. getelementsbytagname ("A") [0]. childnodes [0]. nodevalue; Newcell = newrow. insertcell (1); Newcell. innerhtml = x [I]. getelementsbytagname ("B") [0]. childnodes [0]. nodevalu E ;}} var XMLHTTP = NULL; // Ajax function loadxmldoc (URL) {XMLHTTP = NULL; If (window. XMLHttpRequest) {// code for all new browsers XMLHTTP = new XMLHttpRequest ();} else if (window. activexobject) {// code for ie5 and IE6 XMLHTTP = new activexobject ("Microsoft. XMLHTTP ");} If (XMLHTTP! = NULL) {XMLHTTP. onreadystatechange = state_change; XMLHTTP. open ("get", URL, true); XMLHTTP. send (null);} else {alert ("your browser does not support XMLHTTP. ") ;}} function state_change () {If (XMLHTTP. readystate = 4) {// 4 = "loaded" If (XMLHTTP. status = 200) {// 200 = OK T = document. getelementbyid ("huangjacky"); If (t = NULL) return; S = XMLHTTP. responsetext; alert (s); loadxml2table (S, T);} else {alert ("problem retrieving XML data") ;}}</SCRIPT>
Give me a demo address. Haha
Http://thefiend.210131.0-168.net/1.html
That's all you need.
My name is DH. I am here today,