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

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

Contributor ,
May 13, 2015 May 13, 2015

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');

}

TOPICS
ActionScript
546
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
LEGEND ,
May 13, 2015 May 13, 2015

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

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
Contributor ,
Aug 07, 2015 Aug 07, 2015
LATEST

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