Today, kiddie provides another method to use Flash for cross-origin operations. Flash cross-origin operations are restricted. However, the cross-origin configuration of Flash is relatively simple. You only need to place crossdomain. xml under the root directory of the site. Cross-origin operations of Ajax have always been a problem. Currently, the main solutions include:
1. JSONP (must be supported on the server)
2. IFrame (operations can only be performed between subdomains)
3. Page proxy (this is omnipotent)
4. Access-Control-Allow-Origin (supported by the new browser, you need to set the Header on the server)
Today, kiddie provides another method to use Flash for cross-origin operations. Flash cross-origin operations are restricted. However, the cross-origin configuration of Flash is relatively simple. You only need to place crossdomain. xml under the root directory of the site. As for crossdomain. xml usage, you can look at this article: http://www.jb51.net/article/25485.htm this article.
For this series of operations, the kiddies have been encapsulated as jQuery plug-ins and will be attached at the end of the article.
Usage:
1. Introduce jQuery and ajaxf. js files on the page.
2. Insert the following code on the page. First install Flash on the page.
The Code is as follows:
$ (Document). ready (function (){
$. Ajaxf. install ('/Files/zsea/flash4ajax.swf ');
});
3. Call a method to obtain remote data.
The following describes in detail the methods provided by the plug-in:
$. Ajaxf. install (swfpath)
Install Flash on the page. You can specify the Flash path.
$. Ajaxf. ready (function (){})
The function executed after Flash is loaded.
$. Ajaxf. isReady ()
Whether the Flash has been loaded. Return Value: Boolean
$. Ajaxf. ajax (p)
Native ajax calls are supported. p is an object, including callback, callback function, type, method type, json, text, xml, script, url, and data read address; method: The request method. It supports get, post, data, sent data, contentType, request contentType header, header, Object, and additional request headers.
$. Ajaxf. get (url, data, callback, type)
Get Data
$. Ajaxf. post (url, data, callback, type)
Get data through post
We will not explain the meaning of the letter as soon as you read the name.
$. Ajaxf. getText (url, data, callback)
$. Ajaxf. getJSON (url, data, callback)
$. Ajaxf. getScript (url, data, callback)
$. Ajaxf. postJSON (url, data, callback)
$. Ajaxf. postText (url, data, callback)
The following shows how to obtain the HTML code of the Youku homepage.
The Code is as follows: