Skip to main content
wfzen
Inspiring
May 13, 2015 11:48 PM UTC
Question

Pass data to ASP and then to database without leaving the page

I have the script like the one below to POST and go to a ASP page and ASP takes care of database integration.

It works when initiated with a button. It will go to the ASP page and submit data to SQL database. How can I modify it, so it will just send the data to ASP without leaving the current page with SWF?

Thanks for the help,

function sendResultToSQL(ev:MouseEvent):void

{

      // create a URLRequest object with the target URL:

      var url:String = 'http://whatever the page.asp';

      var urlRequest:URLRequest = new URLRequest(url);

      // create a URLVariables object and add all the values you want to send with their identifiers:

      var urlVariables : URLVariables = new URLVariables();

      urlVariables['score'] = score;

      urlVariables['q1'] = q1;

      urlVariables['q2'] = q2;

      urlVariables['q3'] = q3;

... all the data to pass to ASP page and database

      // add the urlVariables to the urlRequest

      urlRequest.data = urlVariables;

      // set the method to post (default is GET)

      urlRequest.method = URLRequestMethod.POST;

      // use navigateToURL to send the urlRequest, use '_self' to open in the same window

      navigateToURL(urlRequest, '_self');

}

This topic is closed to new replies. Start a new post to keep the conversation going.

2 replies

Ned Murphy
Legend
May 14, 2015 12:26 AM UTC

Instead of using navigateToURL, look into using the URLLoader class to send the data to the ASP file

Translate
wfzen
wfzenAuthor
Inspiring
Aug 7, 2015 7:33 PM UTC

Thank you, Ned. I switched "navigateToURL" with "URLLoader" in the last line, but it does not save any data. Can you elaborate on the coding to make it work?

Thanks!

Translate