Skip navigation
Currently Being Moderated

Post Data to ASP page

Sep 26, 2012 12:49 PM

Hi,

 

I'm trying without success to write an AS3 script to post data to a server ASP page (which is scripted in ASP to insert the data into a DB. The ASP script does not return any data to Flash.). It is set up so that it only receives data and does not send any data back.

 

I've written a script which follows, but I get back a trace of "error" (see script), and when I independently check the DB, no new data that I am trying to send, is received. So, not working.

 

 

storeBtn.addEventListener(MouseEvent.CLICK,dbStore,false,0,true);
function dbStore(event:MouseEvent):void{
var g2:String;
if (selectGm == true){
g2 = "abc";
}
if (selectGf == true){
g2 = "xyz";
}
var scriptPage6:String ="https://mysite.com/ASPpage.asp";
var request6:URLRequest = new URLRequest(scriptPage6);
request6.method = URLRequestMethod.POST;
var variables6:URLVariables = new URLVariables();
variables6.aaa = data88;
variables6.bbb = data99;
variables6.name = name6;//carried over in the script from text input in an earlier frame: var name6:String = username_txt.text;
variables6.ggg = g2;
var loader6:URLLoader = new URLLoader();
loader6.dataFormat = URLLoaderDataFormat.VARIABLES;
loader6.addEventListener(Event.COMPLETE, handleComplete6);
loader6.load(request6);
//request6.data = variables6;
}
var msg:String;
function handleComplete6 (event:Event):void{
var msg = event.target.data;
if(msg=="true"){
trace("Done!");
} else{
trace("Error: "+msg);
}
}

 

I must be doing something wrong and would appreciate any help. I'm not sure how to send data when no return data is needed or requested?

 

The goal is simply to send 4 items to the ASP page (aaa, bbb, name and ggg) which can process and insert these into a DB.

 

Regards,

 
Replies
  • Currently Being Moderated
    Sep 26, 2012 1:10 PM   in reply to saratogacoach

    storeBtn.addEventListener(MouseEvent.CLICK,dbStore,false,0,true);
    function dbStore(event:MouseEvent):void{
    var g2:String;
    if (selectGm == true){
    g2 = "abc";
    }
    if (selectGf == true){
    g2 = "xyz";
    }
    var scriptPage6:String ="https://mysite.com/ASPpage.asp";
    var request6:URLRequest = new URLRequest(scriptPage6);
    request6.method = URLRequestMethod.POST;
    var variables6:URLVariables = new URLVariables();
    variables6.aaa = data88;
    variables6.bbb = data99;
    variables6.name = name6;//carried over in the script from text input in an earlier frame: var name6:String = username_txt.text;
    variables6.ggg = g2;


    var loader6:URLLoader = new URLLoader();
    loader6.addEventListener(Event.COMPLETE, handleComplete6);
    loader6.load(request6);
    }
    var msg:String;


    function handleComplete6 (event:Event):void{
    trace("Done!");
    }

     
    |
    Mark as:
  • kglad
    62,001 posts
    Jul 21, 2002
    Currently Being Moderated
    Sep 26, 2012 1:11 PM   in reply to saratogacoach

    why is

     

    //request6.data = variables6;

     

    commented out??

     
    |
    Mark as:
  • kglad
    62,001 posts
    Jul 21, 2002
    Currently Being Moderated
    Sep 26, 2012 4:57 PM   in reply to saratogacoach

    yes, it's needed.  that (assigning the data property of your urlrequest) is the only way to send variables/values to your asp script.

     

    after you fix that, eliminate your handleComplete6 function because you're not returning anything from your asp script. or, even better, have your asp script return something when it completes:

     

    Response.Write "asp script complete."

     
    |
    Mark as:
  • kglad
    62,001 posts
    Jul 21, 2002
    Currently Being Moderated
    Sep 27, 2012 4:50 AM   in reply to saratogacoach

    you're welcome.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points