Ajaj, a new plug-in recently developed, is a substitute for ajax and deserves attention.

Source: Internet
Author: User

Just found a new device Ajaj, Asynchronous JavaScript And JOSN.

This technology can achieve non-refreshing interaction like ajax, but it can be cross-origin.

The principle is to dynamically create a script tag, point the src attribute to an exotic url, and then call the local javacript method in the data returned from a foreign country for data processing.

In this way, the cross-origin is good.

Click here to download detailed documentation http://sinaurl.cn/hbra2g

Compared with Ajax, Ajaj has the following advantages and disadvantages:
1. He cannot replace ajax
2. Ajax uses asynchronous requests by default, with few synchronous methods. Ajaj only supports asynchronous requests.
3. Ajax requests in both get and post methods are OK, but this Ajaj will be very troublesome if it is used in post method.
4. Ajaj will not load the server
5. The page where Ajaj is located must be a standard HTML page with complete 6. Because security issues occur when cross-origin access is allowed, it is best to use Ajaj in areas with low security requirements.
7. Ajaj does not use XMLHTTP, but uses the SRC of the SCRIPT label to reference external scripts. The data processing efficiency is higher than that of XMLHTTP.

Attached test code:
Merchant. php (Server A background processing)
<? Php
IF (array_key_exists ("I", $ _ GET )){
$ I = $ _ GET ['I'];
} Else {
$ I = 0;
}
If ($ I! = 5 ){
Echo 'alert ("fei5 ");';
} Else {
Echo 'alert ("555 ");';
}
?>
Document. write ('<a href = "#" onclick = "CreateScriptObj (\' @. php? I = 5 \ ') "> Start </a> ');

(Server B, called at the front end)
<? Php
IF (array_key_exists ("I", $ _ GET )){
$ I = $ _ GET ['I'];
} Else {
$ I = 0;
}
If ($ I! = 5 ){
Echo 'alert ("fei5 ");';
} Else {
Echo 'alert ("555 ");';
}
?>
Document. write ('<a href = "#" onclick = "CreateScriptObj (\' @. php? I = 5 \ ') "> Start </a> ');

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.