3 Replies Latest reply on May 27, 2006 5:54 PM by Juankpro

    getURL / LoadVars with POSTing values

      Hi

      Seems like there are lots of getURL / LoadVar problems and this one seems bizarre to me.

      I am trying to submit form entries in Flash to an external perl script. I understand that locally Flash won't function with getURL now, so have uploaded it to my server and tried testing it.

      I tried just calling a getURL from within Flash with the following:

      wholeString = " http://myHost.com/cgi-bin/FormMailer.pl?recipient=1&subject=NewFlashTest";
      getURL(wholeString,"_self", "POST");

      I know that the perl script and this format function as I've sent the following from a form within my website:

      <form method="post" action=" http://myhost.com/cgi-bin/FormMailer.pl?recipient=1&subject=NewTest">
      <input type="hidden" name="recipient" value="1" />
      <!--input type="hidden" name="subject" value="Webdesign feedback form" /-->
      Name: <input type="text" name="name" /><br />
      Address: <input type="text" name="mail_address" /><br />
      E-mail: <input type="text" name="email" /><br />
      Telephone: <input type="text" name="telephone" /><br />
      <input type="submit" />
      </form>

      This HTML form functioned exactly as it should. However, my Flash script did call the function, but the perl script returned saying that no recipient was passed to it. Yet the complete URL, including the recipient value is contained in the address bar of IE.

      So, I tried with LoadVars instead. I tried this:

      myObject = new LoadVars();
      myObject.recipient = 1;
      myObject.subject = "Testing of LoadVars";
      myObject.name = "with LoadVars";
      myObject.email = "jimbo@hotmail.com";
      myObject.send(" http://myhost.com/cgi-bin/FormMailer.pl" ,"_self","POST" );

      At the moment this is situated in a function called from an onRelease on a button.

      However, this appeared to do nothing and I receive nothing from the perl script mailer.

      Anyone have any suggestions? Thanks.
        • 1. Re: getURL / LoadVars with POSTing values
          This appears to be working after a couple of tweaks. For anybody who is also having this problem, I removed the "POST" from the send function:
          myObject = new LoadVars();
          myObject.recipient = 1;
          myObject.subject = "Testing of LoadVars";
          myObject.name = "with LoadVars";
          myObject.email = "jimbo@hotmail.com";
          myObject.telephone = "+41 208 783 3984";
          myObject.address = "24 King Drive";
          myObject.send(" http://myHost.com/cgi-bin/FormMailer.pl" ,"_self");
          • 2. Re: getURL / LoadVars with POSTing values
            Juankpro Level 2
            It seems that you are mixing POST variables with GET variables in a wrong way
            1 person found this helpful
            • 3. Re: getURL / LoadVars with POSTing values
              Juankpro Level 2
              When you use your form you are sending the variables recipient and subject using both methods, GET and POST. Maybe this is why the script works because it depends on this fact (it is not the right thing to do though).
              In your second example using LoadVars change the last line to:

              myObject.send(" http://myhost.com/cgi-bin/FormMailer.pl?recipient=1&subject=NewTest", "_self", "POST");

              This way you'll be doing the same as your form is doing.
              If on the other hand it still doesn't work maybe it is due to security restrictions. If the host you are calling for example is myHost.com from flash the this is the same domain you need to use for the html page that contains the flash file. Otherwise flash will be blocked. Flash blocks itself from sending and reding data from internet if the file is in your local machine and viceversa. It blocks comunication too when the file is not in the same domain. Even if the domain is the same but you write it different. For example if you have your own server you can start you app using the domain localhost. But if flash is calling data using 127.0.0.1 then flash will block communication even though both ways of communication refer to the same server.