Javascript learning experience

Source: Internet
Author: User
I have been pondering javascript For the past few days, but I have never had any practical experience. Now I think there are a lot of practical errors. I will continue to summarize the errors in the future. The key is to reduce the debugging time, cainiao: 1. js usually has a local error, and the following functions won't continue to be executed (originally... syntaxHighlighter. all (); I have been thinking about javascript For the past few days. I have never had any practical experience. Now I think there are a lot of practical errors. I will keep summing up the errors in the future. The key is to reduce the debugging time, cainiao:
1. js usually has a local error, and the following functions won't continue to be executed (something that I thought was normal, ...)
2. Why should a parameter change be added behind the requested servlet when an open () request is sent to the server to inform the server that this is a new request ??? Otherwise, the request fails in IE8.
Var bojingNum = 0;
// Define a variable to store the xmlHttpRequest object
Var xmlHttp = null;
// This function is used to create an xmlHttpRequest object.
Function createXMLHttpRequest ()
{
If (window. ActiveXObject) // The ActiveXObject object is a control provided by IE browser, so some online banking only supports the IE browser of this control.
{
XmlHttp = new ActiveXObject ("Microsoft. XMLHTTP"); // The object generated by the IE browser

} Else if (window. XMLHttpRequest) // other browsers except IE
{
XmlHttp = new XMLHttpRequest ();
}
}
// This is a method for refreshing the Statistical Chart through ajax
Function autoFlush ()
{
// Create date variable time variable
Var tempTime = new Date ();
Var tempParameter = tempTime. getTime ();
// Create an xmlHttpRequest object
CreateXMLHttpRequest ();
If (xmlHttp! = Null)
{
// Place a time parameter here to let the server know that this is a new request
XmlHttp. open ("GET", "SerialDataSvt? Tmd = "+ tempParameter );
// Bind the status trigger to a function
XmlHttp. onreadystatechange = processor;

// Send the request
XmlHttp. send (null );
}


}
// Process the xml document returned from the server
Function processor ()
{
// Define a variable to store the results returned by the slave server
Var result;
If (xmlHttp. readyState = 4) // if the response is complete
{
If (xmlHttp. status = 200) // if the returned result is successful
{

// Retrieve the child nodes of all counter labels of the xml document returned by the server
Result = xmlHttp. responseXML. getElementsByTagName ("data"); // alert (result );

// Parse the data in xml and update the Statistical Chart status

For (var I = 0; I <result. length; I ++)
{
// Used to update the statistics image status
Var id = result [I]. getAttribute ("id"); // alert (id );
Var dir = result [I]. getAttribute ("dir"); // alert (dir );

Var datas = xmlHttp. responseXML. getElementsByTagName ("dataContent") [0]. childNodes [0]. nodeValue;
Var addTime = xmlHttp. responseXML. getElementsByTagName ("addTime") [0]. childNodes [0]. nodeValue;


If (datas. substring (17,18) = "1 ")
{
Document. getElementById ("yujing" + (I + 1). innerHTML =" Alarming";
Document. getElementById ("yujingPic" + (I + 1). style. display = 'block ';
BojingNum ++;
Document. getElementById ("yujingNum" + (I + 1). innerHTML = "alert times:" + bojingNum;
}
Else
{
Document. getElementById ("yujing" + (I + 1). innerHTML = "no alert ";
Document. getElementById ("yujingPic" + (I + 1). style. display = 'none ';
}
Document. getElementById ("n_nodeID" + I). innerHTML = id + dir;
Document. getElementById ("n_nodeData" + I). innerHTML = datas;
Document. getElementById ("n_nodeTime" + I). innerHTML = addTime;

Document. getElementById ("s_nodeID" + I). innerHTML = id + dir;
Document. getElementById ("s_nodeData" + I). innerHTML = datas;
Document. getElementById ("s_nodeTime" + I). innerHTML = addTime;

Document. getElementById ("e_nodeID" + I). innerHTML = id + dir;
Document. getElementById ("e_nodeData" + I). innerHTML = datas;
Document. getElementById ("e_nodeTime" + I). innerHTML = addTime;

Document. getElementById ("w_nodeID" + I). innerHTML = id + dir;
Document. getElementById ("w_nodeData" + I). innerHTML = datas;
Document. getElementById ("w_nodeTime" + I). innerHTML = addTime;

}
}
}
}
// Execute the autoFlush method once every second.
SetInterval (FIG, 2000 );
Related Article

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.