Flipkart

Friday, April 23, 2010

Flex: Get Response from HTTPService

 <mx:Script>
        <![CDATA[
           import mx.rpc.events.ResultEvent;
           import mx.rpc.events.FaultEvent;
           import mx.controls.Alert;
           private var alert:Alert;



            private function send_data():void {
                userRequest.send();
            }

            private function httpService_fault(evt:FaultEvent):void {
                var title:String = evt.type + " (" + evt.fault.faultCode + ")";
                     Alert.show(title);
            }
          
             private function httpService_result(evt:ResultEvent):void {
              var msg:String = userRequest.lastResult.responce;
              if(msg == '1') {
                    var url:String = "http://localhost/flex/firstapp/home.html";
                    var request:URLRequest = new URLRequest(url);
                    navigateToURL(request);                
                   //Alert.show('correct');
              }else{
                  Alert.show(msg);
              }
             
            }
   
          
        ]]>
    </mx:Script>

      <mx:HTTPService
            id="userRequest"
            url="http://localhost/flex/firstapp/index.php"
            method="POST"
            fault="httpService_fault(event);"
            result="httpService_result(event)"
            resultFormat="e4x"

            >

No comments:

Post a Comment