The Ajax usage may be messy.

Source: Internet
Author: User

With the emergence and prevalence of Ajax technology, this is ignored as a second-stream Programming Language JavaScript scripts have also begun to become popular, and a large number of JavaScript frameworks have emerged, such as Microsoft ASP. NET Ajax and jquery. Ajax has become an essential part of these Script frameworks, and the development of AJAX is becoming simpler and simpler.

Ajax is a method that does not load scripts. Its oldest implementation method is to use IFRAME to load remote scripts and use top. function to call the method of the parent form. Use the target attribute of HTML such as a to specify. Simple but complicated maintenance in the later stage, and difficult to bridge. Next, the emergence of XMLHttpRequest objects simplifies Ajax development to a certain extent. However, there are many different implementations in different browsers, such as XMLHttpRequest and activeobject in IE in Firefox, and it only provides few and simple Ajax requests and processing. Many JavaScript frameworks have emerged. In XMLHttpRequest-based encapsulation and class library provision, Ajax programming is greatly simplified. Among them, the most famous and popular jquery framework. What we need to say here is that jquery implements cross-origin issues very well.

Next I will talk about some of the Ajax notes or skills that I have come up with. The thinking may be a bit messy. Please forgive me.

1: X in Ajax is XML, which can also easily load XML, but I personally think XML is a bad method. First of all, we all know that XML is a strict data storage method with a lot of redundant information. XML processing is also complicated. XML can achieve cross-platform performance, such as WebService. This is a WebService advantage, but it is also a fatal drawback. It is based on XML redundant information, so the speed in the distributed system is also very slow.

A json object is a lightweight storage method. It is stored as a name-value pair. In addition, JavaScript scripts are a natural JSON object and can be directly used without conversion. In addition, the. NET Framework now provides support for JSON serialization. In my opinion, JSON is the preferred choice.

2: cache and browser cache are often used on the server for performance and other considerations. Sometimes we need to avoid it. The simplest way is to add a timestamp, "default. aspx? Time = "+ datetime. Now. You can avoid caching. If you are using jquery Ajax, you can directly set cache: false to disable caching.

3: Pay attention to Content-Type in Ajax programming, such as HTML, text, JSON, XML, and script. Many of our unreasonable errors are often set here. Pay attention to the Content-Type of Ajax and the Content-Type output by the server. On the server side, we need to output the response. Clear (), response. contenttype = type, and response. Flush () and response. Clos () at completion ().

4: Ajax is not representative of high interaction and high user experience. Our applications should not use Ajax technology first, Because if Ajax technology is not used well, it will be counterproductive. In addition, if Ajax is used, we have to prepare a retreat for the customer, because Ajax requests may cause errors for various reasons.

5: Ajax is based on client scripts, which means that there are some security risks and some of our sensitive information is easily exposed. Especially online scriptsCodeI think this is a bad habit. It is easy to lose the candle.

If you have any experience or suggestions, please leave a message. If you have any questions, leave a message and I will try my best to reply as soon as possible.

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.