Skip to main content
November 16, 2007
Question

.send v .sendAndLoad

  • November 16, 2007
  • 14 replies
  • 783 views
Hi all,

I have a simple sendForm(); function that compiles vars, builds a form in AS2 and sends the form to a CGI script on the host ISP for email delivery. I use the LoadVars object to collect and send the vars to the CGI script. The final part of the function sends the data to a URL and targets a blank window for a return message and uses the POST method. All works fine when the form is submitted using a simple button and the .send method of the LoadVars class.

However, I want to prevent the default CGI script return page from appearing by preventing the browser opening a new window (or replacing the swf using _self), so I used the .sendAndLoad method and replaced the 'window' target with a gotoAndStop frame, which carries a successful deliver message.

The problem is that the form date is not posted to the URL, but the swf does advance to the gotoAndStop frame, which shows the successful delivery message. Can anyone tell me why the date is not being sent to the URL with the .sendAndLoad method?

Code:

var feedbackForm:LoadVars = new LoadVars();

function sendForm() {
feedbackForm.recipient = "info@somedomain.com";
other form constructs here
feedbackForm.sendAndLoad(" http://formmail.dreamhost.com/cgi-bin/formmail.cgi", gotoAndStop("correct"), "POST");
}

//onRelease
this.contactForm.submitBtn.onRelease = function() {
if ( form validation here) {
gotoAndStop("error");
} else {
sendForm();
}
}

This problem is vexing to say the least and it is not the first time that I have had .sendAndLoad issues. Any help is very much appreciated.
This topic has been closed for replies.

14 replies

Inspiring
November 16, 2007
Actually I just saw its dreamhost, probably you have to live with whatever it returns?

If so, just use the onData handler instead of onLoad. The argument is the raw text that the script sends in response. I guess its might be a web page. You could ignore it then and move on.
Inspiring
November 16, 2007
No problem - I adjusted your code with an example that (hopefully) will help.
November 16, 2007
Excellent answer, thanks.
Inspiring
November 16, 2007
The second argument for the sendAndLoad method is an Object. I've never seen it used other than with another LoadVars (or sometimes the same LoadVars) instance or an XML instance.

I would code a receiving LoadVars for your sendAndLoad and wait for its onLoad handler to fire then advance to your 'correct' frame. Or just sendAndLoad, advance to a 'correct, please wait' frame and then confirm when the onLoad handler fires.