The first time I started enterprise-level applications, I felt that the logic must be very clear and there are many different concepts.
In the Baidu Editor, how does one complete the value of the slave server to render the table? Console is required. log (editor); in the official API, we have already told you that the write method is setContent (). Here, as long as we can input the final string, We can initialize it, draw any desired node.
After sending () is complete, onreadystatechange = function () {} begins with the previous AJAX code. This section of AJAX is compatible with the browser, and has been learned from Nicolas's book.
Copy codeThe Code is as follows: function AJAX (){
If (typeof XMLHttpRequest! = "Undefined "){
Return new XMLHttpRequest ();
} Else if (typeof ActiveXObject! = "Undefined "){
If (typeof arguments. callee. activeXString! = "String "){
Var versions = ["MSXML2.XMLHttp. 6.0", "MSXML2.XMLHttp. 3.0", "MSXML2.XMLHttp"];
For (var I = 0, len = versions. length; I <len; I ++ ){
Try {
Var xhr = new ActiveXObject (versions [I]);
Arguments. callee. activeXString = versions [I];
Return xhr;
} Catch (ex ){
}
}
}
Return new ActiveXObject (arguments. callee. activeXString );
} Else {
Throw new Error ("Error ");
}
}
In the JSON dataset, we know that this is a pair of key values. When we get a Json object from the server, we need to parse it and then generate the DOM node we need. For example, the following is a JSON dataset.Copy codeThe Code is as follows :{
"Head ":{
"Rows": 3,
"Cells": 2
},
"Body ":{
"Rows": 3,
"Cells": 2
}
}
Next, the obtained data is stored in responseText. Therefore, you need to set a variable to accept it, So var a = eval ("(" + xhr. responseText + ")"); in this step, the entire Json object is retrieved from the server. Then for in, you can obtain the data stored in the Json object.Copy codeThe Code is as follows: for (var B in ){
Console. log (a [B]. rows );
}
// For in traverses the Json object, and B gets the key value.
After obtaining the specific JSON dataset, you can use + = to spell the node string, use + = to spell the node string, from top to bottom, judge, and loop, you only need to set an empty variable at the beginning to receive all of this.
In the last step, editor. setContent (Json) is used to initialize the editing area of the editor and render the node from the server.
Industry is superior to diligence, and it is not suitable for industry. Think about things and get rid of things. The growth of newcomers lies in summary. All articles and examples are self-summary only for learning and communication.