AJAX and DOM running experience

Source: Internet
Author: User

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.

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.