Hi,

I have this code. It works perfect but I would like to get alerted only when
I have some kind of error in my test.cfm file. Instead, the 'errorAlert()'
function always is triggered :(

Any idea's on how to make this work only when I have problems in my
test.cfmfile?

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

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

    <mx:HTTPService
      id="srv"
      url="http://myserver.flex/test.cfm";
      fault="errorAlert();"
      method="POST">

        <mx:request>
            <firstName>{firstName.text}</firstName>
            <lastName>{lastName.text}</lastName>
            <salary>{salary.text}</salary>
            <startDate>{startDate.text}</startDate>
        </mx:request>
    </mx:HTTPService>


 <mx:Script>
  <![CDATA[
   import mx.controls.Alert;

   private function errorAlert():void {
    Alert.show('Error!');
   }
  ]]>
 </mx:Script>


    <mx:Form>
        <mx:FormItem label="First Name">
            <mx:TextInput id="firstName"/>
        </mx:FormItem>
        <mx:FormItem label="Last Name">
            <mx:TextInput id="lastName"/>
        </mx:FormItem>
        <mx:FormItem label="Salary">
            <mx:TextInput id="salary"/>
        </mx:FormItem>
        <mx:FormItem label="Start Date">
            <mx:DateField id="startDate"/>
        </mx:FormItem>
        <mx:FormItem>
            <mx:Button label="Add Employee" click="srv.send()"/>
        </mx:FormItem>
    </mx:Form>

</mx:Application>

Reply via email to