I have been depressed by DOM operations in AJAX for several days. Today I finally realized that self-learning is bitter, and a bitter snot is a tear. I will give some lessons, wake up later, and the old bird will stop watching it.
1. do not confuse XML operations in the DOM with those in the browser. For example, getElementByName is the DOM operation of the document Object embedded in the browser. It is wrong to operate responseXML. in the browser, you can use document. getElementsByName (''tagname'') [0]. value to obtain the control value, but you must use getElementsByName (''tagname'') [0] When operating responseXML. firstChild. data (same as nodeValue ).
2. If you want to apply responseXML, write response. setContentType ("text/xml") in the server's response service ");
If your AJAX Code fails once, the page may still be incorrect even after you change it correctly. This is caused by annoying browser cache,
I 've been stuck here for at least one day.
Therefore, you 'd better write the statement response. setHeader ("Cache-Control", "no-cache") that disables caching on the server response page ");
(The number of milliseconds after the request url + the current system is also a method. Use new Date (). getTime () in js to obtain the millisecond difference between the system and a specific time .).
3. Some IE standards do not fully comply with W3C. For example:
We all know the onchange event for monitoring controls, but the text control IE does not support the onchange attribute. Fortunately, we use the onpropertychange event to listen to the text.
Another example is that setAtrribute () can be used to set CSS attributes in browsers other than IE, but is not supported in IE. We also use EObj. style. stylearrtibute = value.
<