Copy link to clipboard
Copied
Hi all, hopefully somebody may be able to help me with a little problem, I am trying to pass variables from flash to a database via asp. Now I know the .asp side of things are working reason being I use the navigateToURL(), which works like a charm, however Im trying to avoid some security issues and avoid it opening up another window. Which brings me to using URLLoader, its getting the variables and "sending them", but Im not getting anything in the database. here is my code for the function.
function sendX(theVar1:String, theVar2:String, theVar3:String, theVar4:String)
{
var url:String = "thewebpage.asp";
var myRequest:URLRequest = new URLRequest(url);
var variables:URLVariables = new URLVariables();
var myLoader:URLLoader = new URLLoader();
variables.userNm = theVar1;
variables.userLoc = theVar2;
variables.usrRating = theVar3;
variables.custType = theVar4;
myRequest.method = URLRequestMethod.POST;
myRequest.data = variables;
try
{
myLoader.load(myRequest);
trace("sucess",variables);
}
catch (e:Error)
{
trace("fail");
}
}
information is being gathered from 3 txt fields and a button all of which are strings. Like I said have no issues getting the vars, just having them show up in the database. This was also done using a fully qualifed url and the partial with no results. I appreciate any feedback, thanks.
Message was edited by: andjelkovich2012
Copy link to clipboard
Copied
if you know your asp page is receiving the variables correctly, the problem is between your asp page and your database.
Copy link to clipboard
Copied
Ok, I can check into that, but do you have any idea why the navigateToURL() is working compared to using URLLOADER?
Copy link to clipboard
Copied
show your navigateToURL code so i can see if you're handling your variables the same way.
Copy link to clipboard
Copied
yes in my try catch code I replaced "myLoader.load(myRequest)" with "navigateToURL(myRequest)" and that worked, but still wondering what I am doing wrong with URLLoader. I though it could be a cashing issue, I have tried different browsers, but have yet to tackle this problem. appreciate the help
Copy link to clipboard
Copied
maybe your loader is being gc'd. try:
var myLoader:URLLoader;
function sendX(theVar1:String, theVar2:String, theVar3:String, theVar4:String)
{
var url:String = "thewebpage.asp";
var myRequest:URLRequest = new URLRequest(url);
var variables:URLVariables = new URLVariables();
myLoader = new URLLoader();
variables.userNm = theVar1;
variables.userLoc = theVar2;
variables.usrRating = theVar3;
variables.custType = theVar4;
myRequest.method = URLRequestMethod.POST;
myRequest.data = variables;
try
{
myLoader.load(myRequest);
trace("sucess",variables);
}
catch (e:Error)
{
trace("fail");
}
}
Copy link to clipboard
Copied
no help with that unfortunately, still plugging away and doing some more research to see if I am doing something wrong, unless I am misunderstanding the entire concept of URLLoader, this method is used to send information correct? I also added a HTTPStatusEvent and getting the following reply. Is there another way to send information besides navigateToURL? I used sendToURL but was encountering the same issues. Thanks again for your help
[HTTPStatusEvent type="httpStatus" bubbles=false cancelable=false eventPhase=2 status=200]
Copy link to clipboard
Copied
you can send and receive data. you would do well to add a complete listener to see if your asp file is returning something (like an error message).
Find more inspiration, events, and resources on the new Adobe Community
Explore Now