FAQs in Ajax Program Development

Source: Internet
Author: User

1. When the XML document returned by the response in Ajax and action is incorrectly formatted, eclipse debug cannot enter the action.
2. For Ajax cache problems, you must add XMLHTTP. setRequestHeader ("If-modified-since", "0.
3. If you set printwriter out = response. getwriter () instead of Ajax commit, JSP will generate Chinese garbled characters.
4. Causes of XML garbled characters returned by Ajax
Response. setcontenttype ("text/XML; charset = GBK ");
Printwriter out = response. getwriter ();
This will take effect. If so:
Printwriter out = response. getwriter ();
Response. setcontenttype ("text/XML; charset = GBK ");
Therefore, response. setcontenttype ("text/XML; charset = GBK"); does not work, so the returned result is garbled. This problem has taken a long time, Code Take a closer look.
5. Ajax form submission
XMLHTTP. setRequestHeader ("Content-Type", "application/X-WWW-form-urlencoded ");
Since UTF-8 encoding is passed in, the corresponding transcoding is required when an action or servlet is accepted.
6. dynamic page client webpage cache Ajax does not run
Registering Program Ajax may be used when you do not need to refresh the web page to see the results of programs such as whether the verification code username is available, uploading files online, deleting files, and voting programs. The principle is that JavaScript reads the current user operation data of a webpage through events such as onchange, onclick, and onmouseout, and then transmits the data to a dynamic webpage for processing.

The dynamic page called by Ajax should not be loaded into the client cache. Similarly, the trackback program of the blog often fails to receive information. You can try to avoid writing cached statements before the dynamic page of The trackback program is written.

In addition, you can also program code
+ Math. Random ();
So that a random number is submitted each time to avoid client caching.

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.