DOM operations in AJAX

Source: Internet
Author: User

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.
 

<

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.