I have been depressed by DOM operations in AJAX for several days. Today I finally understand that self-learning is bitter, and a bitter snot makes a tear,
Give me some lessons and wake up later.
1. Do not mix 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.
ResponseXML is incorrect. In the browser, you can use document. getElementsByName ('tagname') [0]. value to obtain the control value, but in the operation
In responseXML, you must use getElementsByName ('tagname') [0]. 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 that the onchange event is used to monitor changes to controls. However, the text control IE does not support the onchange attribute. Fortunately, we
Onpropertychange event to listen to text.
For example, setAtrribute () can be used to set CSS attributes in browsers other than IE, but it is not supported in IE. We also use
EObj. style. stylearrti.pdf = value.