Ultrashock Forums > Flash > ActionScript
LoadVars & CGI question

You are currently viewing our website as a guest which gives you limited access to forums, files and other resources.

Click here to join now for free, and start interacting with our members, download files and much more!

Click here if you are looking for our Flash files and other professional assets.
 
Post Reply | View first unread | Rate Thread Search this Thread | Thread Tools | Display Modes

#1
Bookmark and Share!
LoadVars & CGI question
Old 2003-03-04

This is really annoying me

I have written a CGI script (in C) which sets the content_type of its response to "text/html".

My Flash movie is able to send its variables to the CGI script (using Flas's default content_type) and the CGI script correctly interprets the variables.

The problem is with the response sent back from the script: Flash can't seem to parse the name=variable list.

I've tried setting the content_type of my LoadVars objects to "html/text", but Flash still doesn't get it right. I've also attempted to get my CGI script to respond using the "application/x-www-form-urlencoded" content_type, and that doesn't work either. AAaaargh!

Any ideas ? Anything ?
postbit arrow 6 comments | 166 views postbit arrow Reply: with Quote   
Registered User
bandit is offline
seperator
Posts: 4
2003-01-03
seperator

Ultrashock Member Comments:
PEDALSPEED PEDALSPEED is offline PEDALSPEED lives in United States 2003-03-04 #2 Old  
Post your sendAndLoad code.
Reply With Quote  
bandit bandit is offline 2003-03-04 #3 Old  
my code
Here's my test code (Main TimeLine). Note that the values being returned are being decoded into properties of my dataReceiver object - but the values are wrong i.e. they are not being decoded properly.

Thanks for any help...

**

dataSender = new LoadVars();
//dataSender.contentType = "html/text";
dataReceiver = new LoadVars();
//dataReceiver.contentType = "html/text";

dataReceiver.onLoad = function(success){
if (success){
trace(dataReceiver.toString());
trace(dataReceiver.contentType);
trace(dataReceiver.OptionValue);

} else {
trace("Call to CGI script Failed");
}
}

CalcButton.onPress = function(){
dataSender.num1 = 50;
dataSender.num2 = 50;
dataSender.num3 = 10;
...
dataSender.sendAndLoad("http://<servername>/scripts/myscript.cgi",dataReceiver,"POST");
}
Reply With Quote  
PEDALSPEED PEDALSPEED is offline PEDALSPEED lives in United States 2003-03-04 #4 Old  
Code:
htmlText
not
Code:
html/text
Reply With Quote  
PEDALSPEED PEDALSPEED is offline PEDALSPEED lives in United States 2003-03-04 #5 Old  
Try this:

Replace x and y with your name pairs.

Code:
trace(dataReceiver.decode("x=10&y=20")); 
trace(dataReceiver.y);
Also, what are the values supposed to be and what is displayed?
Reply With Quote  
bandit bandit is offline 2003-03-04 #6 Old  
Bug or Plain Weird ?
Pedalspeed,

First, thanks for your help - I really appreciate your time to respond to my post.

I solved my problem:

It turns out that the LoadVars variables being sent to the server are being sent in the reverse order to which they were defined in my code!!

my code:

dataSender.Num1=50;
dataSender.Num2=10;
dataSender.Num3=33;

results in the following string being sent to the server:

"Num3=33&Num2=10&Num1=50"

Because my CGI script identifies name/value pairs by their order and not their name, the wrong input was being processed.

I'm not familiar enough with CGI script coding 'best practices' in general to come to any definite conclusions - but I'd say this is more likely a bug than a feature ?!

Bernard.
Reply With Quote  
PEDALSPEED PEDALSPEED is offline PEDALSPEED lives in United States 2003-03-04 #7 Old  
Changing
Code:
dataSender.Num3 = numA;
dataSender.Num2 = numB;
dataSender.Num1 = numC;
To:
Code:
dataSender.Num1 = numA;
dataSender.Num2 = numB;
dataSender.Num3 = numC;
Changes the order and keeps the results.
Reply With Quote  
Thread Tools
Display Modes Rate This Thread
Rate This Thread: