AS3 - Sending POST data to another domain without loading (Sandbox security)

做~自己de王妃 提交于 2019-12-13 01:10:01

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!