10 articles on ajax development code

Source: Internet
Author: User

1. Ensure security at the front and back ends.
The front-end cannot be used alone for security verification. The backend must also have a filtering mechanism to check the information sent in front. Since Ajax will also receive information sent from the backend, it is necessary to check the information without trust.

2. Try to transmit data using the http post method
The GET method is easy for people with interest to obtain information. Although POST is not foolproof, it is at least safer than GET.

3. Do not directly use the eval function to evoke JSON objects.
JSON (JavaScript Object Notation) is a JavaScript Object Data Format. When it is uploaded from the backend to the Ajax program, it must be converted from a string to an Object using the eval function, in this case, you must first check whether illegal characters exist in the documents to prevent illegal programs from being started by the machine.

4. Restrict the HTML syntax Available to Users
Many Ajax websites allow users to use HTML syntax in messages, and some specific syntax should be strictly limited, such as <plaintext> or <! -This type of syntax will invalidate the code that is placed later.

5. Disable the JavaScript syntax for webpages that can leave messages
Although I thought it was incredible at first glance, it did happen on some forum platforms, opening the door to XSS attacks.

6. Pay attention to security issues when using the Ajax framework
As hackers use JavaScript to launch attacks with each passing day, when using the Ajax framework, web page developers must pay attention to whether the framework has any preventive actions against certain methods.

7. let users know what they are in
When Ajax loads a large amount of data, it sometimes gives the user the illusion that it is not sure whether the pressed button has taken effect. Therefore, developers must design appropriate prompts so that users can understand the current program execution status.

8. Keep a small amount of transmission
The flexibility of Ajax is to dynamically change the amount of local data. Therefore, only a small amount of data can be transferred to achieve the highest benefit. If a large data table needs to be changed through DOM operations, it is better to operate on the backend program and database, with higher efficiency.

9. Balance ease of use with content
Although Ajax provides users with ease of use during browsing, if all the content is generated through Ajax, the search engine will not be able to index the data. Therefore, the content-related part should be used with caution.

10. Implement the elegant degradation Principle
Websites should not use Ajax in an all-round way, but only add some interactivity. users who do not support JavaScript must consider and try to avoid using these functions, so that they can browse the website normally.

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.