I’m working on an interactive quiz where the user’s responses will be incremented to a poll in a CMS. I have a url that automatically increments the answer choice in a poll, so I would like to use sendToURL to call the url without actually passing any data or variables. It seems to work with navigateToURL, but that opens a blank window in the browser (a complete nuisance every time you answer a quiz question).
Here is the navigateToURL code that increments the poll successfully, but opens the unwanted browser window
var url:String = "[URL GOES HERE](http://polls.clickability.com/polls?pid=)";
var request:URLRequest = new URLRequest(url);
try {
navigateToURL(request);
} catch (e:Error) {
trace("Navigate to URL failed", e.message);
}
Here is the URLRequestMethod.POST code that increments the poll, but throws an error and distrupts other things because I’m feeding it a dummy variable.
var variables:URLVariables = new URLVariables("name=Franklin");
var request:URLRequest = new URLRequest();
request.url = "URL GOES HERE";
request.method = URLRequestMethod.POST;
request.data = variables;
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, completeHandler);
try
{
loader.load(request);
}
catch (error:Error)
{
trace("Unable to load URL");
}
function completeHandler(event:Event):void
{
trace(event.target.data.welcomeMessage);
}
Suggestions? I tried replacing “navigateToURL” in the first option to sendToURL and it wasn’t incrementing the poll.