Skip to main content
wfzen
Inspiring
May 13, 2015
Question

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

  • May 13, 2015
  • 1 reply
  • 560 views

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 has been closed for replies.

1 reply

Ned Murphy
Legend
May 14, 2015

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

wfzen
wfzenAuthor
Inspiring
August 7, 2015

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!