PDA

View Full Version : LoadVars() - Why so impossible to make work


mrand01
07-15-2003, 12:40 PM
Trying to make flash send vars to an ASP page, then have the ASP page send back a different var...for some reason, this isn't working...I have code thats virtually identical to this that works, so I really don't have any idea why this won't.


myArray = sendString.join(",");
aLength = sendString.length;
username = user_txt.text;
sending.myArray = myArray;
sending.aLength = aLength;
sending.username = user_txt.text;

sending.sendAndLoad("http://localhost/onDemandTest/results.asp",sending,"POST");

sending.onLoad = function() {
if(this.finish == "True") {
user_txt._visible = true;
user_txt.text = "Success";
}
else {
user_txt.text = "Nope";
}
}


ASP

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<%
Dim aLength
Dim Answers
Dim username
Dim strVDS

aLength = Request("aLength")
Answers = Request("myArray")
username = Request("username")

strVDS = "&finish=True"
Response.Write strVDS
%>
</body>
</html>

tg
07-15-2003, 12:49 PM
are you running this in test mode (the authoring environment)? or from your web page?

'POST' can give you some funky results (ie. sometimes it doesn't work) from test mode.


if this is not the case, then try this:

place this line immediately before your sendAndLoad() action:

sending.send("http://localhost/onDemandTest/results.asp","_blank","POST");


this will open your asp page inside a new blank window, you will see any results (error messages or the correct page).

if there are error messages, try to figure out what those(asp errors are sometimes wierd), and see where that gets you. once you have it working, just comment/delete the send line.

mrand01
07-15-2003, 12:54 PM
I've tried that, my ASP is fine. It has to be my AS, but I can't see any problems (PS, I am using a local IIS server to run this)

freddycodes
07-15-2003, 01:03 PM
Well your asp page has html output in it, so flash cannot read the variables properly. Try changing it to be


<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Dim aLength
Dim Answers
Dim username
Dim strVDS

aLength = Request("aLength")
Answers = Request("myArray")
username = Request("username")

strVDS = "&finish=True"
Response.Write strVDS
%>

mrand01
07-15-2003, 01:08 PM
still not workin...

freddycodes
07-15-2003, 01:12 PM
Maybe a little more information would help here. Whats not working? Have you tried just tracing this.finish() inside the onLoad handler?

This worked perfect for me on my setup.

The as


sending = new LoadVars();
receiving = new LoadVars();

sending.myArray = "A,B,C,D";
sending.aLength = 4;
sending.username = "louie";
sending.sendAndLoad("http://localhost:8100/results.asp",receiving,"POST");

receiving.onLoad = function() {
trace (this.finish);
if(this.finish == "True") {
user_txt._visible = true;
user_txt.text = "Success";
}
else {
user_txt.text = "Nope";
}
}


the asp


<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Dim aLength
Dim Answers
Dim username
Dim strVDS

aLength = Request("aLength")
Answers = Request("myArray")
username = Request("username")

strVDS = "&finish=True"
Response.Write strVDS
%>



I get "True" in the output window.

BTW I don't just post without testing. Make sur eyou have all the steps completed, and next time give more feedback than "its still not working" like what steps you took to correct the problem and what response you are getting back from the asp script.

mrand01
07-15-2003, 01:13 PM
sorry bout that...i got it working, for some reason the CODEPAGE 1252 was messing the ASP up...dreamweaver put that there, but oh well, thanks guys