duanjiashai9140 2012-10-25 00:43 采纳率: 0%
浏览 28
已采纳

Flex AS3 - 无法发送POST数据

This would be idea of AS code (Flex/AIR platform):

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)
}

And PHP:

<?php

    echo '<?xml version="1.0" encoding="utf-8"?>
    <result>result:'.$_POST['username'].'</result>
';

?>

This is all I get

enter image description here

(Problem is that with PHP I can't read POST data... or they are not send):


Any point to solution would be apreciated.

  • 写回答

3条回答 默认 最新

  • douhuiyan2772 2012-12-09 00:56
    关注

    Changed this line

    var request:URLRequest = new URLRequest(config.domain+'/oms/request/user/login');
    

    to this

    var request:URLRequest = new URLRequest(config.domain+'/oms/request/user/login/index.php');
    

    and it worked...

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 我的数据无法存进链表里
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端