Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

having trouble sending vars to database(asp)

Explorer ,
Jan 08, 2013 Jan 08, 2013

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

TOPICS
ActionScript
1.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 08, 2013 Jan 08, 2013

if you know your asp page is receiving the variables correctly, the problem is between your asp page and your database.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 08, 2013 Jan 08, 2013

Ok, I can check into that, but do you have any idea why the navigateToURL() is working compared to using URLLOADER? 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 08, 2013 Jan 08, 2013

show your navigateToURL code so i can see if you're handling your variables the same way.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 09, 2013 Jan 09, 2013

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 09, 2013 Jan 09, 2013

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");
}
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 09, 2013 Jan 09, 2013

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]

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 09, 2013 Jan 09, 2013
LATEST

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).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines