问题
I need to send POST Data to a ASP script on a different domain name ( without loading data).
var scriptRequest :URLRequest = new URLRequest( 'http://someExternalCart.com/cart.asp' );
scriptRequest.method = URLRequestMethod.POST;
scriptRequest.data = scriptVars;
It works with navigateToUrl, BUT I don't want to get redirected to that page, I only want to send the data.
I have tried this:
var ldr :URLLoader = new URLLoader();
ldr.load( scriptRequest );
But I am getting the sandbox security error.
Is there any other way of sending the data without redirection/page reload and without loading (which causes the security error)?
回答1:
If you don't have access to the server to add the crossdomain.xml security policy file, you will need to set up a proxy on your own server that passes the request through for you (something like http://xmlrpcflash.mattism.com/proxy_info.php).
回答2:
To avoid sandbox error, you need a crossdomain file on "http://someExternalCart.com/".
http://www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html
Or you can use a script (php, asp...) on your webserver that will act as a proxy.
http://www.snorkl.tv/2011/04/get-data-into-flash-from-other-domains-with-crossdomain-xml-or-php-proxy-script/
来源:https://stackoverflow.com/questions/7161839/as3-sending-post-data-to-another-domain-without-loading-sandbox-security