With Ajax, the Ajax support was not very good at the time, all involved in the bottom, no existing framework for you to call. Now the common questions are listed below.
1, coding problems
Note that the files that Ajax is going to fetch are UTF-8 encoded. The Chinese will be garbled after the GB2312 code is passed back to browse. If you use VBScript, you can convert, but VBScript only supports IE.
So, choosing UTF-8 encoding is the way to go once and for all.
2. Clear the cache of server-side files.
When retrieving a server-side file with XMLHTTP, the file is cached on the browser side. The next time you fetch the file, you will not go to the server to fetch the file. Therefore, for files that are frequently refreshed, be sure to specify the expiration time of the file.
3. When to use XML
The X in Ajax refers to XML, but is real XML the best solution? XML files are larger when the same amount of information is passed, compared to JSON. So often json is a better choice. However, you can also directly output JavaScript execution, which is often more efficient: no need to write complex callback functions. But the security issue has to be paid more attention. Health.hljmlyfcyy.com
4. Two ways of Ajax
Some people's foundation may not be very solid, do not know very much about the principle of Ajax, then you know what two ways of AJAX implementation?
The oldest is an iframe to load a Web page containing JS, the script in this page uses Top.function to invoke the function in the parent page. However, you can specify the target of a and the target of the form, so that you can actually easily send the form without serializing the form. Of course, later on a little bit of trouble, there are problems are not easy to solve.
Later it was the way XMLHTTP components. It's also a skill to pick out when and how.
5. Cross-domain issues
If a script is not in the same domain, the two cannot be called to each other. If the IFRAME is a Web page in another domain, you cannot access the contents of the parent page. If you need to access remote XML, such as an RSS feed, it is recommended that you use a server-side script to relay. It is a very good solution if the traffic is not very large. However, flipping through the jquery handbook finds that it can invoke (execute) cross-domain scripts, but what to do is not clear. You can download the jquery unencrypted version to study.
6, security issues
On the server side, although the client can preprocess a lot of things, you still have to pay attention to a word: all the variables from the client are harmful. In the case of Ajax, many programmers tend to loosen their guard. This makes the security problem more covert. If it is open-source program, then the problem will be exposed in front of the netizen immediately, black box of the case, often be invaded or can not find out the reason. Rl.hrbfc120.com
Conclusion: In fact, in this era of the framework of the time to write AJAX implementation code is not much, many JS framework integrates the AJAX call function, some server-side framework, such as Thinkphp also integrates Ajax. However, understanding some of the underlying things can help eliminate bugs and improve the performance of AJAX applications.
Things to be aware of in AJAX applications