Copy link to clipboard
Copied
Hi Everyone,
I am struggling with urlvariables of AS3, they are sending variables with GET method while i am using POST method, Please help,
Here is my code:
----
AS3
----
req = new URLRequest(url);
user_lead = new URLVariables();
vars['email'] = "test@test.com";
vars['content']= "dummy Contents here";
req.data = vars;
req.method = URLRequestMethod.POST;
ldr = new URLLoader();
ldr.dataFormat = URLLoaderDataFormat.TEXT;
//ldr.dataFormat = URLLoaderDataFormat.VARIABLES;
ldr.addEventListener(Event.COMPLETE, checkResponse);
ldr.addEventListener(IOErrorEvent.IO_ERROR, IOErrorHandler);
ldr.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
ldr.load(req);
navigateToURL(req);
-----
PHP:
-----
<?php
echo $_POST["email"]; //NOT WORKING
//echo $_REQUEST["email"]; working fine
//echo $_GET["email"]; working fine
?>
Thanks,
Maani
Copy link to clipboard
Copied
1. remove that navigateToURL
2. what is vars?
3. what's the purpose of user_lead?
Copy link to clipboard
Copied
You should be using the var "user_lead" to set your vars and pass that to the .data property.
e.g.
var req:URLRequest = new URLRequest(url);
var user_lead:URLVariables = new URLVariables();
user_lead.email = "test@test.com";
user_lead.content = "dummy Contents here";
req.data = user_lead;
req.method = URLRequestMethod.POST;
ldr:URLLoader = new URLLoader();
ldr.dataFormat = URLLoaderDataFormat.VARIABLES;
ldr.addEventListener(Event.COMPLETE, checkResponse);
ldr.addEventListener(IOErrorEvent.IO_ERROR, IOErrorHandler);
ldr.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
ldr.load(req);
Find more inspiration, events, and resources on the new Adobe Community
Explore Now