Copy link to clipboard
Copied
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');
}
Copy link to clipboard
Copied
Instead of using navigateToURL, look into using the URLLoader class to send the data to the ASP file
Copy link to clipboard
Copied
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!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now