views:

180

answers:

2

I have a contact form that connects to my site's back-end, the form submits just fine but I get no server response. It's always 'undefined'. I'm worried it may be because of this, but I was hoping maybe one of you smarter folks could help me find either a workaround or if it isn't because of that (note: most likely), then maybe you could tell me what I'm doing wrong.

//==========================================================
public function openForm():void {
//==========================================================
    var sendForm:URLLoader = new URLLoader();
    var newFile:FileReference = new FileReference();
    var request:URLRequest = new URLRequest(urlString);
    if (form1.planby.visible && form1.planby.upload.selected) {
     newFile.addEventListener(HTTPStatusEvent.HTTP_STATUS, responseStatus);
     newFile.upload(request, "attache[attachment]", false);
    } else {
     sendForm.addEventListener(HTTPStatusEvent.HTTP_STATUS, responseStatus);
     sendForm.load(request);
    }
}

//==========================================================
function responseStatus(e:HTTPStatusEvent):void {
//==========================================================
    //e.status == "undefined" according to debugger
    if (e.status == 200) {
     openPage("success");
    } else {
     openPage("error");
    }
}
+2  A: 

In my experience the getting the status codes of HTTP calls is just plain unreliable unless you are deploying in AIR.

With that in mind you are generally better off having the server send back some simple text verifying that it everything worked ok - if you don't get that text back then go into your error mode.

Yeah, it's a pain in the butt and everyone in the community is desperately hoping that Adobe fixes this problem soon.

Branden Hall
I've pretty much brushed off those event's as well, even doing a simple connect success event, I've had to resort to making a small request that returns a Boolean value from the server.
Tyler Egeto
Thanks Branden. I guess that's what I'll have to do. It'd be nice if they fixed that.
Zach
+1  A: 

Shouldn't you be listening for the Event.COMPLETE event rather than the HTTP_STATUS event (which as Branden says, is unreliable)?

quoo
Yeah I'll do that with URLVariables and I should be good. Thanks again quoo!
Zach