Call Php page : Php « Development « Flex






Call Php page

Call Php page
         

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300">
    <mx:HTTPService url="http://localhost/service.php" id="service" result="serviceResult(event)" fault="serviceFault(event)"
     method="GET" contentType="application/xml" useProxy="false">
         <mx:request xmlns="">
             <id>{requestedId}</id>
         </mx:request>
     </mx:HTTPService>
     <mx:Script>
         
             import mx.rpc.events.FaultEvent;
             import mx.rpc.events.ResultEvent;

             [Bindable]
             private var requestedId:Number;

            //trace the result of the service out
            private function serviceResult(event:Event):void {
                trace(service.lastResult.name);
            }

            // in the event that the service faults or times out
            private function serviceFault(event:Event):void {
                trace('broken service');
            }

            private function callService():void {
                requestedId = input.text as Number;
                service.send()
            }

       
     </mx:Script>
     <mx:TextInput id="input"/>
     <mx:Button label="get user name" click="callService()"/>
     <mx:Text text="{service.lastResult.name}"/>
     <mx:Text text="{service.lastResult.age}"/>
</mx:Application>

   
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Send text message to a Php serverSend text message to a Php server
2.Read text message from Php serverRead text message from Php server