Forums Forums (
-   ActionScript 3.0 (
-   -   URLLoader using POST fails to send variables (

pseudobiotic 11-19-2008 07:11 PM

URLLoader using POST fails to send variables
hopefully this is simple and I'm just missing something obvious. I'm trying to hit a php page using POST data and load the response. what actually happens is the php page is hit using POST but without data. if I navigateToURL with the URLRequest instead of URLLoader.load, the data is sent.



some_button.addEventListener( MouseEvent.CLICK, _handle_click);

function _handle_click( in_mouse_event:MouseEvent):void {
        var url_variables:URLVariables = new URLVariables();
        url_variables.a = 1;
        url_variables.b = 2;

        var url_request:URLRequest = new URLRequest( "index.php");
        url_request.method = URLRequestMethod.POST; = url_variables;
        var url_loader:URLLoader = new URLLoader();
        url_loader.dataFormat = URLLoaderDataFormat.VARIABLES;
        url_loader.addEventListener( Event.COMPLETE, _handle_complete);
        url_loader.addEventListener( IOErrorEvent.IO_ERROR, _handle_io_error);
        url_loader.load( url_request);
        //navigateToURL( url_request);

function _handle_complete( in_event:Event):void {
        trace( "complete");
function _handle_io_error( in_event:IOErrorEvent):void {
        trace( "io error");

thank you for any help

creatify 11-19-2008 07:28 PM

I don't see anything wrong with your code unless I'm missing something... what does your php look like, is it set to grab the vars _POST or _GET?

pseudobiotic 11-19-2008 09:20 PM

thanks for your reply creatify! the php isn't doing anything other than
PHP Code:


I'll make an example and post it.

pseudobiotic 11-19-2008 10:37 PM

sorry! I'd been misdiagnosing a problem. I'd been watching the requests and responses using firebug (and firebug lied!). the code had been working correctly all along. I only figured it out after trying to build an example that traced out the response w/o firebug. thanks for your help!

SarK0Y 11-20-2008 01:26 AM

Hi, pseudobiotic
i use so:
var sendData="param1=xxx.xx&param2=yyyy...yy"
var variables:URLVariables = new URLVariables(sendData);
var request:URLRequest = new URLRequest();
request.url = "";
request.method = URLRequestMethod.POST; = variables;
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, function(evt:Event):void {

pseudobiotic 11-20-2008 01:30 AM

cool! thanks for your reply SarK0Y

maximillion 11-21-2008 06:58 PM

pseudobiotic - I have this exact problem - all POST data is empty when I replay the request in Live HTTp Headers (firefox add-on) the POStT array is empty?? although I can see POST data in the header???

navigateToURL() - posts the data just fine and this is really baffling me

ActionScript Code:
var variables:URLVariables = new URLVariables(postData); variables.key = 'dsfsgh';          variables.desc = 'dsfsfds'          var request:URLRequest = new URLRequest(_submissionURL); request.method  = URLRequestMethod.POST;   = variables;            _subLoader = new URLLoader(); _subLoader.addEventListener( Event.COMPLETE, submissionCompleteHandler ); _subLoader.addEventListener( HTTPStatusEvent.HTTP_STATUS, onHTTPStatus ); _subLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler); _subLoader.dataFormat = URLLoaderDataFormat.VARIABLES _subLoader.load( request );

can anyone help?


maximillion 11-21-2008 09:16 PM

the solution to my problem was that 'replaying' the request from flash in 'http live headers' and 'tamper data' add-ons for firefox didnt not replay them as flash had sent them and caused problems reading the POST data in php.

I hope that helps others!

All times are GMT. The time now is 01:22 AM.

Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger