0 Replies Latest reply on May 7, 2010 7:34 AM by ed.rottner

    navigateToURL where URLRequest method = POST always defaults to GET

    ed.rottner

      Hi there

       

      I'm trying to invoke a PHP URL using the HTTP POST method combined with parameters to pass to a form. The test app is an AIR application as per the code below. Whilst the default browser is launched with the URL specified, my issue is that the method used at runtime is always HTTP GET not POST. I'm not sure what I'm doing wrong. I'd be really grateful if somebody could review and point out my mistake!

       

      Many thanks

       

      Ed

       

       


      <?xml version="1.0" encoding="utf-8"?>

      <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

      <mx:Script>

      <![CDATA[

      import flash.net.navigateToURL;

       

        private function newWin(url:String):void {

                      var urlRequest:URLRequest = new URLRequest(url);

      var variables:URLVariables = new URLVariables();

          var rhArray:Array = new Array(new URLRequestHeader("Content-Type", "text/html"));


       

      urlRequest.requestHeaders = rhArray;

                  variables.username = "admin";

                  variables.password = "admin";

                  variables.domain   = "Default";

                  urlRequest.data = variables;               

      urlRequest.method = "POST";

                      navigateToURL(urlRequest);

                 

                  }


      private function buttonclick() : void

      {

      this.newWin("http://10.0.5.176/contactq/index.php");

      }

      ]]>

      </mx:Script>

       

      <mx:Canvas id = "myCanvas" height="400" width="400">

      <mx:Button id="myButton" click="buttonclick();" x="169" y="166" width="91" label="Invoke URL"/>

      </mx:Canvas>

      </mx:WindowedApplication>