这将是 AS 代码(Flex/AIR 平台)的想法:
protected function login_btn_login_clickHandler(event:MouseEvent):void
{
var urlLoader:URLLoader = new URLLoader();
var request:URLRequest = new URLRequest(config.domain+'/oms/request/user/login');
Alert.show(login_inp_username.text) // OK!
var requestVars:URLVariables = new URLVariables();
requestVars.username = login_inp_username.text;
requestVars.password = login_inp_password.text;
request.data = requestVars;
request.method = URLRequestMethod.POST
urlLoader.load(request);
urlLoader.addEventListener(Event.COMPLETE,login_evt_complete);
urlLoader.addEventListener(IOErrorEvent.IO_ERROR,login_evt_ioerror);
}
protected function login_evt_ioerror(e:Event):void {
Alert.show('IO Error: Check connection')
}
protected function login_evt_complete(e:Event):void {
// var response:XML = e.currentTarget;
var response:XML = new XML(e.target.data);
Alert.show(response)
}
和 PHP:
<?php
echo '<?xml version="1.0" encoding="utf-8"?>
<result>result:'.$_POST['username'].'</result>
';
?>
这就是我得到的全部
(问题是使用 PHP 我无法读取 POST 数据......或者它们没有发送):
任何解决方案都将不胜感激。