3 Replies Latest reply on Mar 5, 2008 2:13 PM by jbellis2

    Preparing "response" to sendAndLoad

      If this is a pure Perl/CGI issue, just say so. I've succeeded, with no perl skills, in creating a simple perl program that saves a file (some XML) to my web server in response to an actionscript "send." But with that technique my perl script opens a new window in which I display a success message.
      I want to improve that by using "sendAndLoad" so that I receive some active confirmation back and don't have a new window. But I don't detect any response back from my perl script. I don't see any good explanations on the web of populating the "response" object. Is that because "stdout" becomes "response?" Can someone point me to a page that explains the situation? Do I need to write lines for every header item... content-type, length, etc.

      If you're curious, the "send" technique occurs with the Save button at http://s91524683.onlinehome.us/lexonomy/
        • 1. Re: Preparing "response" to sendAndLoad
          Ben2 Level 1
          In Flash:

          var lv_Q:LoadVars = new LoadVars(); //object holding the data to send
          var lv_A:LoadVars = new LoadVars(); //object to hold the data received

          lv_A.onLoad = function(success:Boolean) {
          if (success) {
          my_text.text = lv_A.responseVar; // display confirmation
          } else {
          my_text.text = "Error."; // script didnt load

          lv_Q.sendAndLoad("yourscriptname.php", lv_A, "POST");

          The Perl/CGI script should output to the browser the following text:

          &responseVar=Thankyou for whatever

          When you get a positive response back from the script, you can get flash to do whatever you want

          Hope this helps
          • 2. Re: Preparing "response" to sendAndLoad
            jbellis2 Level 1
            Thanks, I'll give it a try.
            • 3. Re: Preparing "response" to sendAndLoad
              jbellis2 Level 1
              Ben, got it working with your advice. I had previously seen and used that same code, from the help, but I guess I never got it fully working. The .onload never fired success or failure. Possibly the function definition, which I hadn't copied verbatim. In retrospect I realize that meant my Actionscript was not functioning (because sendandload ensures an "onload" irrespective of one's CGI. Once I got it working, I was able to prove that Perl as simple as
              print "Content-type:text/xml\n\n";
              print "...fromserver\n";
              works, even without the #!/usr... line. So this means the answer to my original confusion is:
              "Any print output from a Perl program to the default output (STDOUT standard output?) automatically becomes the 'response' that is sent back. You need only precede it with a content type statement"... or something along those lines.
              Thanks, Jack