If it's just get, there will be more solutions, such as jsonp.
Post is a little troublesome. I searched the internet and found a lot of solutions. I feel that this method of using flash for proxy is quite good, and the browser compatibility is also very good, however, the premise is that the Web server is managed by yourself. Because of flash-based security rules, you need to put a crossdomain in the root directory of the website. XML, all of which are allowed here:
<? XML version = "1.0"?> <Br/> <! Doctype cross-domain-Policy System "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd"> <br/> <! -- Policy file for xmlsocket: // socks.mysite.com --> <br/> <cross-domain-Policy> <br/> <site-control permitted-Cross-Domain-policies = "Master-only"/> <br/> <allow-access-from domain = "*"/> <br/> <allow-http-request-headers-from domain = "*" headers = "*" /> <br/> </Cross-Domain-Policy>
I have seen some developers in China package their own, but there are still some gaps in this comparison. We suggest using this. He has made Plug-ins for prototype, dojo, and jquery, which is really convenient:
Http://flxhr.flensed.com/
Take jquery as an example:
1. First download flxhr and the corresponding jquery plug-in:
A> http://flxhr.flensed.com/code/releases/jquery/jquery.flXHRproxy.js
B> http://plugins.jquery.com/project/XHR
Http://flxhr.flensed.com/download.php
2. embedded scripts on the page:
<SCRIPT type = "text/JavaScript" src = "xxx/flxhr. js"> </SCRIPT>
<SCRIPT type = "text/JavaScript" src = "xxx/1.4.2/jquery. Min. js"> </SCRIPT>
<SCRIPT type = "text/JavaScript" src = "xxx/jquery. xhr. js"> </SCRIPT>
<SCRIPT type = "text/JavaScript" src = "xxx/jquery. flxhrproxy. js"> </SCRIPT>
3. Example Code :VaR usecount = 0; jquery (document ). ready (function () {jquery. flxhrproxy. registeroptions ("http://test.getify.com/flXHR-tests/", {xmlresponsetext: false, loadpolicyurl: "http://test.getify.com/flXHR-tests/policy.php"}) ;}); function doit () {var COUNT = (usecount + 1 ); for (VAR I = 0; I <count; I ++) {var requestbody = "My name is jquery-test (#" + (++ usecount) + ")"; jquery. ajaxsetup ({transport: 'flxhrproxy', error: handleerror}); jquery. post ("http://test.getify.com/flXHR-tests/textme.php", requestbody, handleloading, "text/plain") ;}} function handleloading (data, status, xhrobj) {If (xhrobj. readystate = 4) {alert ("readystate:" + xhrobj. readystate + "/nresponsetext:" + xhrobj. responsetext + "/nstatus:" + xhrobj. status + "/nstatustext:" + xhrobj. statustext + "/nsource Object ID:" + xhrobj. instanceid) ;}} function handleerror (xhrobj, errtype, errobj) {alert ("error:" + errobj. number + "/ntype:" + errobj. name + "/ndescription:" + errobj. description + "/nsource Object ID:" + errobj. srcelement. instanceid );}