Problem with HttpService POST
Posted
by Lost_in_code
on Stack Overflow
See other posts from Stack Overflow
or by Lost_in_code
Published on 2010-06-02T08:29:24Z
Indexed on
2010/06/02
8:33 UTC
Read the original article
Hit count: 206
flex
|actionscript-3
I'm trying to send some data to PHP using HTTPService POST but for some reason it's not working.
The same example works with GET but not with POST:
private function start():void{
var param:Object = {};
param.date = "2010-10-10";
userRequest.send(param);
userRequest.addEventListener(ResultEvent.RESULT, result);
userRequest.addEventListener(FaultEvent.FAULT, fault);
}
private function fault(e:FaultEvent):void{
trace(e.message);
}
private function result(e:ResultEvent):void{
trace(e.result);
}
<mx:HTTPService id="userRequest"
url="http://localhost:8888/api"
useProxy="false"
method="POST"/>
And here's the PHP code:
$d = $_POST['date'];
echo $d;
if($d == ""){
trace("Date not found!");
die();
}
This is the error I'm getting:
"Error #2032: Stream Error. URL: http://localhost:8888/api"
But when I change the method in HTTPService to GET and in PHP I get the result as expected - PHP sends back the date:
2010-10-10
What am I doing wrong?
© Stack Overflow or respective owner