Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Ajax

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article will explain in detail how to use Ajax. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

Ajax is a method that is no longer a loading script, and its oldest implementation is to use iframe to load remote scripts and use top.Function to call the parent form. It is specified using the target attribute of HTML such as a. Simple but late maintenance is complicated and troublesome in terms of leapfrogging. Then the emergence of XMLHttpRequest object simplifies the development of Ajax to a certain extent, but there are many differences in different browsers, such as XMLHttpRequest in FireFox and ActiveObject in IE, and it only provides few and simple Ajax requests and processing. Nowadays, there are many JavaScript frameworks, which greatly simplify our Ajax programming in XMLHttpRequest-based encapsulation and the provision of class libraries. One of the most famous and popular jQuery framework. What needs to be said here is that jQuery implements cross-domain problems very well.

Below I would like to say a few points of my current Ajax attention or skills, thinking may be a little confused, please forgive me, will not be good, also please forgive me.

The X in 1:Ajax is XML, it can also easily load XML, but I personally think shelves and XML is a very bad way. First of all, we all know that XML is a strict way of data storage, there is a lot of redundant information. In addition, the processing of XML also has a certain complexity. XML can achieve cross-platform, such as WebService, which is an advantage of WebService, but it is also a fatal disadvantage, it is based on XML redundant information, so the speed is also very slow in distribution.

By contrast, the Json object is a lightweight storage method, which is stored in the form of name-value pairs. And the JavaScript script itself is a natural Json object that can be used without conversion, and now the .NET Framework provides support for Json serialization. My personal opinion is that Json is the first choice.

2: caching and browser caching are often available on the server side for performance and other considerations. Sometimes we need to avoid, the easiest way is to add a timestamp, "Default.aspx?time=" + DateTime.Now. Caching can be avoided. If you are using Jquery's Ajax, you can directly set cache:false to disable caching.

3: what you need to pay attention to in Ajax programming is Content-Type, which includes HTML, Text, Json, XML, Script and so on. Many of our unprovoked mistakes are often set up here. You need to pay attention to the Content-Type of the Ajax and the Content-Type output from the server. Then there is the server side, where we need to output Response.Clear (), Response.ContentType=Type before, and Response.Flush () and Response.Clos () at completion.

4:Ajax is not representative of high interaction and high user experience, which needs to be explained. We should not choose Ajax technology for our applications, because if Ajax technology is not used very well, it will be counterproductive. And if we want to use Ajax, we have to prepare a fallback for the customer, because ajax requests can go wrong for a variety of reasons.

5:Ajax must be based on client script, which means that there is a certain security risk, it is easy to expose some of our sensitive information. Especially the online script code erosion, some of us often in the online Copy down just under the test to join our project, I think this is a very bad habit. It's easy to lose more than you gain.

This is the end of the article on "how to use Ajax". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report