Ten rules for AJAX development

Source: Internet
Author: User
Tags object end eval http post json
Introducing the ten Code of AJAX development is believed to be useful to developers.


1. Before and after the end to do a good job of security checks
Can not rely on the front-end to do security verification work, the back end must have a filtration mechanism to test the data from the front. Because Ajax will also receive data from the backend, the information should be distrusted and must be checked.



2. Try to transmit data in HTTP POST method



3. Do not invoke JSON objects directly with the Eval function
JSON is a JavaScript object name data format, upload from the back to the AJAX program, you must use the Eval function to convert it from the string into an object, you must first check the data has illegal characters in order to prevent illegal programs to enable.



4. Limit the HTML syntax available to the user
Many Ajax sites allow users to use HTML syntax in their messages, and some specific syntax should be strictly restricted, such as

or!--syntax, which invalidates the code that is placed behind it.




5. Use JavaScript syntax for page pages that are not allowed to leave messages
Although at first blush, it did happen on some tribal Gopping platforms, which opened the door to XSS attacks.



6. Using the AJAX framework, you must pay attention to security issues
As hackers use JavaScript to attack with each passing day, when Web developers use the AJAX framework, we must pay attention to whether the framework itself to some specific methods of prevention and control behavior.



7. Let users know where they are
When Ajax loads a large amount of data, it sometimes gives the user the illusion that it is not sure if the button just pressed has any effect. Therefore, the developer must design the appropriate hints to let the user understand the current program implementation status.



8. Maintain a small amount of transmission
The flexibility of Ajax is to change the amount of local data dynamically, so small amounts of data transfer can achieve maximum benefit. If a large table is to be changed through the operation of the DOM, it is better to operate from the backend program and the database.



9. Attention to ease of use and content balance
Ajax, while it makes browsing easy for users, can cause the search engine to fail to index data if all content is generated through Ajax. So the content-related part needs to be used with care Ajax.



10. Implementation of the graceful demotion principle
If the site is not comprehensive Ajax technology, but only for local increase interactivity, then must consider the user does not support JavaScript, try to do not use these features, under the premise that they can also normal browsing the site.




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.